https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125311

            Bug ID: 125311
           Summary: -fcheck=no-bounds doesn't always work
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ajmay81 at gmail dot com
  Target Milestone: ---

If -fcheck=bounds is specified somewhere deep in a build system it cannot be
overridden with -fcheck=no-bounds. Oddly, if -fcheck=all was previously given,
which implies bounds checking, then giving -fcheck=no-bounds afterwards
disables bounds checking.

Trivial program:

program test
integer i(1), j, k
i(:) = 0
j = 2
k = i(j)
end

# > gfortran -fcheck=all -fcheck=no-bounds test.f90 && ./a.out
# > gfortran -fcheck=bounds -fcheck=no-bounds test.f90 && ./a.out
At line 5 of file test.f90
Fortran runtime error: Index '2' of dimension 1 of array 'i' above upper bound
of 1

Error termination. Backtrace:
...

I would expect the second case to behave as the first.

Reply via email to