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

            Bug ID: 108906
           Summary: Bogus may be used uninitialized warning
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

Split-off from  on PR fortran/108621

This shows up with code generated by gfortran internally. The warning is bogus
and (rightly!) disappears when compiled with -Og, -Os, -O1 or higher:


Warning: ‘f.dim[idx.1_32].lbound’ may be used uninitialized
[-Wmaybe-uninitialized]


If I now look at the 021t.ssa dump, I see:

  f.data = 0B;
...
  _1 = f.data;
  cfi.0.base_addr = _1;
...
  _2 = cfi.0.base_addr;
  if (_2 != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 6>; [INV]
...
  <bb 4> :
  _3 = f.dim[idx.1_32].lbound;
...
  <bb 6> :
  fun (&cfi.0);


I get the same result when I use '_2 = f.data' instead, i.e. neither value
propagation works.

The basic block <bb 4> is the only place where idx.1_32 gets used - but as
f.data == NULL, we directly jump to <bb 6>. Seemingly, the range/value
propagation from 'f.data = 0' to '_2 = ' does not work.

* * * 

Testcase – compile with "gfortran -Wall"; a variant is 'subroutine'
instead of 'program' but this does not have any effect, either.


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(inout) :: f_p(:)
end subroutine
end interface

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

nullify(f)
call fun(f)

end

Reply via email to