public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107839] New: spurious "may be used uninitialized" warning while all uses are under "if (c)"
@ 2022-11-23 16:38 vincent-gcc at vinc17 dot net
  2022-11-23 21:00 ` [Bug tree-optimization/107839] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2022-11-23 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107839
           Summary: spurious "may be used uninitialized" warning while all
                    uses are under "if (c)"
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

Consider

int f (int);
void g (int c)
{
  int v;
  if (c)
    v = f(0);
  while (1)
    if (c)
      f(v + v);
}

$ gcc-test -O -Wmaybe-uninitialized -c tst2.c
tst2.c: In function ‘g’:
tst2.c:4:7: warning: ‘v’ may be used uninitialized [-Wmaybe-uninitialized]
    4 |   int v;
      |       ^

All uses of v are under "if (c)", so the warning is incorrect. Note that
replacing "v + v" by "v" makes the warning disappear.

This occurs with GCC 8.4.0 and above up to at least 13.0.0 20220906
(experimental) from the master branch. No warnings with GCC 6.5.0 and below.

Note to myself (to check once this bug is fixed): this testcase is derived from
tmd/binary32/hrcases.c (warning on variable t0).

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

end of thread, other threads:[~2024-01-20 17:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 16:38 [Bug tree-optimization/107839] New: spurious "may be used uninitialized" warning while all uses are under "if (c)" vincent-gcc at vinc17 dot net
2022-11-23 21:00 ` [Bug tree-optimization/107839] " rguenth at gcc dot gnu.org
2022-11-24 10:12 ` rguenth at gcc dot gnu.org
2022-11-24 17:09 ` vincent-gcc at vinc17 dot net
2022-12-05  9:32 ` cvs-commit at gcc dot gnu.org
2022-12-05  9:47 ` rguenth at gcc dot gnu.org
2022-12-12 11:20 ` cvs-commit at gcc dot gnu.org
2024-01-20 17:22 ` pinskia 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).