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

            Bug ID: 108621
           Summary: [12 regression]: bind(c) pointer array spurious
                    maybe-uninitialized warning
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael at scivision dot dev
  Target Milestone: ---

GCC 12 introduced a new regression--spurious Wmaybe-initialized warnings from
example code compiled with:

gfortran -Wall -c main.f90

```
program demo
use, intrinsic :: iso_c_binding, only : c_int
implicit none

interface
subroutine fun(f_p) bind(c)
import c_int
integer(c_int), pointer, intent(out) :: f_p(:)
end subroutine
end interface

integer(c_int), pointer :: f(:)

nullify(f)
call fun(f)

end program
```

emits spurious warnings not seen in GCC < 12:

```
   18 | call fcpoint(f)
      |                 ^
Warning: 'f.dim[idx.1_32].lbound' may be used uninitialized
[-Wmaybe-uninitialized]

   14 | integer(c_int), pointer :: f(:)
      |                                 ^
note: 'f' declared here

   18 | call fcpoint(f)
      |                 ^
Warning: 'f.dim[idx.1_32].ubound' may be used uninitialized
[-Wmaybe-uninitialized]

   14 | integer(c_int), pointer :: f(:)
      |                                 ^
note: 'f' declared here

   18 | call fcpoint(f)
      |                 ^
Warning: 'f.dim[idx.1_32].lbound' may be used uninitialized
[-Wmaybe-uninitialized]

   14 | integer(c_int), pointer :: f(:)
      |                                 ^
note: 'f' declared here

   18 | call fcpoint(f)
      |                 ^
Warning: 'f.dim[idx.1_32].stride' may be used uninitialized
[-Wmaybe-uninitialized]

   14 | integer(c_int), pointer :: f(:)
      |                                 ^
note: 'f' declared her
```

Reply via email to