[flang-commits] [flang] [flang] Produce warning instead of error when bound checking arrays (PR #83011)

Kelvin Li via flang-commits flang-commits at lists.llvm.org
Mon Feb 26 11:39:21 PST 2024


kkwli wrote:

> > So, even though the problem does not show up, I'd argue that a less harsh reaction of Flang on case where it can detect that seems useful, given that other compilers are either completely silent about this detectable case (ifort, ifx) or prefer to warn (gfortran).
> 
> It's a fatal error by default with better compilers (NAG & XLF).

Not really for XLF.
```
$ cat tt.f90

program main
  implicit none
 
  integer, parameter :: N = ONE_OR_TWO
  integer :: array(N)
 
  array(1) = 1
  if (N > 1) then
    array(2) = 2
  endif
 
  write(*,*) array
 
end program main

$ xlf90 -qpreprocess -DONE_OR_TWO=1 tt.f90
"tt.f90", line 10.5: 1516-023 (E) Subscript is out of bounds.
** main   === End of Compilation 1 ===
1501-510  Compilation successful for file tt.f90.
```

https://github.com/llvm/llvm-project/pull/83011


More information about the flang-commits mailing list