public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/108906] New: Bogus may be used uninitialized warning
@ 2023-02-23 17:32 burnus at gcc dot gnu.org
  2023-02-24 12:52 ` [Bug tree-optimization/108906] " rguenth at gcc dot gnu.org
  2023-02-25 10:56 ` cvs-commit at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2023-02-23 17:32 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-25 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 17:32 [Bug middle-end/108906] New: Bogus may be used uninitialized warning burnus at gcc dot gnu.org
2023-02-24 12:52 ` [Bug tree-optimization/108906] " rguenth at gcc dot gnu.org
2023-02-25 10:56 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).