public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/99756] New: bogus -Wmaybe-uninitialized with a use conditional that's a subset of a defining conditional
@ 2021-03-24 23:48 msebor at gcc dot gnu.org
  2021-03-24 23:51 ` [Bug tree-optimization/99756] " msebor at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-24 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99756
           Summary: bogus -Wmaybe-uninitialized with a use conditional
                    that's a subset of a defining conditional
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The following code triggers a spurious -Wmaybe-uninitialized.  There are two
underlying problems: one is a limitation of the uninitialized pass and another
is a missed optimization opportunity described in PR 99755 (the second test for
k results in another read from it instead of reusing the value read previously
in the first conditional).

$ cat t.c && gcc -O2 -S -Wall t.c
extern int a[], i, j, k;

void f (void)
{
  int x;
  if (i > 1 && j > 2 && k > 3)
    x = i + 1;

  if (i == 2 && j == 3 && k == 4)
    a[x] = 0;                 // { dg-bogus "Wmaybe-uninitialized" }
}

t.c: In function ‘f3’:
t.c:28:10: warning: ‘x’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   28 |     a[x] = 0;                 // { dg-bogus "Wmaybe-uninitialized" }
      |     ~~~~~^~~

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

end of thread, other threads:[~2021-12-18 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 23:48 [Bug tree-optimization/99756] New: bogus -Wmaybe-uninitialized with a use conditional that's a subset of a defining conditional msebor at gcc dot gnu.org
2021-03-24 23:51 ` [Bug tree-optimization/99756] " msebor at gcc dot gnu.org
2021-11-30 12:12 ` aldyh at gcc dot gnu.org
2021-12-18 11:47 ` 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).