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

            Bug ID: 125802
           Summary: False positive for [-Wunused-but-set-variable=]
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manfred99 at gmx dot ch
  Target Milestone: ---

cat > unused2.f <<EOF
      program unused2

      integer i,j,arr(4)

      arr=22
      i=1
      DO j=1,4
        IF (j.GT.2) EXIT
        i=j
      ENDDO
      arr(i)=33
      print*,arr

      end
EOF


#> /usr/local/gfortran-17/bin/gfortran -Wall -W unused2.f -o unused2
unused2.f:9:10:

    9 |         i=j
      |          1
Warning: Variable 'i' defined at (1) but never used
[-Wunused-but-set-variable=]


This is with
#> /usr/local/gfortran-17/bin/gfortran --version
GNU Fortran (GCC) 17.0.0 20260614 (experimental)
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to