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

* [Bug tree-optimization/99756] bogus -Wmaybe-uninitialized with a use conditional that's a subset of a defining conditional
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-24 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
         Depends on|                            |99755
             Blocks|                            |24639
      Known to fail|                            |10.2.0, 11.0, 4.1.0, 4.8.4,
                   |                            |4.9.4, 5.5.0, 6.4.0, 7.2.0,
                   |                            |8.3.0, 9.1.0

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The spurious warning goes as far back as GCC 4.1.  It can be avoided either by
improving the optimization or by changing tree-ssa-uninit.c.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99755
[Bug 99755] failure to fold a conditional that's a subset of another expression

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

* [Bug tree-optimization/99756] bogus -Wmaybe-uninitialized with a use conditional that's a subset of a defining conditional
  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
  2 siblings, 0 replies; 4+ messages in thread
From: aldyh at gcc dot gnu.org @ 2021-11-30 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |aldyh at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Fixed in trunk by one of the various improvements to the jump threader:

abulafia:~/bld/t/gcc$ ./cc1 a.c -O2 -Wall -quiet 
abulafia:~/bld/t/gcc$ ./cc1 a.c -O2 -Wall -quiet -fno-thread-jumps
a.c: In function ‘f’:
a.c:10:10: warning: ‘x’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   10 |     a[x] = 0;                 // { dg-bogus "Wmaybe-uninitialized" }
      |     ~~~~~^~~
a.c:5:7: note: ‘x’ was declared here
    5 |   int x;
      |       ^
abulafia:~/bld/t/gcc$

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

* [Bug tree-optimization/99756] bogus -Wmaybe-uninitialized with a use conditional that's a subset of a defining conditional
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-18 11:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

^ 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).