public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning
@ 2014-05-08 14:07 patrick at parcs dot ath.cx
  2014-05-08 14:08 ` [Bug middle-end/61112] " patrick at parcs dot ath.cx
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: patrick at parcs dot ath.cx @ 2014-05-08 14:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61112

            Bug ID: 61112
           Summary: Simple example triggers false-positive
                    -Wmaybe-uninitialized warning
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at parcs dot ath.cx

int p;

void
foo (int x, int y, int z)
{
  int w;
  if (x)
    w = z;
  if (y)
    w = 10;

  if (x || y)
    p = w;
}


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

* [Bug middle-end/61112] Simple example triggers false-positive -Wmaybe-uninitialized warning
  2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
@ 2014-05-08 14:08 ` patrick at parcs dot ath.cx
  2014-05-08 16:27 ` patrick at parcs dot ath.cx
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: patrick at parcs dot ath.cx @ 2014-05-08 14:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61112

--- Comment #1 from patrick at parcs dot ath.cx ---
$ gcc -O2 -Wall this.c
this.c: In function ‘void foo(int, int, int)’:
this.c:13:10: warning: ‘w’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
     p = w;
>From gcc-bugs-return-450991-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 08 14:08:26 2014
Return-Path: <gcc-bugs-return-450991-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17823 invoked by alias); 8 May 2014 14:08:26 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 17791 invoked by uid 48); 8 May 2014 14:08:23 -0000
From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/61111] Infinite recursion between fold_build2_stat_loc and fold_binary_loc
Date: Thu, 08 May 2014 14:08:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rearnsha at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-61111-4-bIsu0uwkEB@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61111-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61111-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg00683.txt.bz2
Content-length: 145

http://gcc.gnu.org/bugzilla/show_bug.cgi?ida111

--- Comment #2 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
This is with r210212.


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

* [Bug middle-end/61112] Simple example triggers false-positive -Wmaybe-uninitialized warning
  2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
  2014-05-08 14:08 ` [Bug middle-end/61112] " patrick at parcs dot ath.cx
@ 2014-05-08 16:27 ` patrick at parcs dot ath.cx
  2021-03-29 19:54 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: patrick at parcs dot ath.cx @ 2014-05-08 16:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61112

--- Comment #2 from patrick at parcs dot ath.cx ---
Relevant contents of -fdump-tree-uninit:

[WORKLIST]: Update worklist with phi: w_2 = PHI <w_1(5), 10(10)>
[CHECK]: examining phi: w_2 = PHI <w_1(5), 10(10)>

[CHECK] Found def edge 1 in w_1 = PHI <w_5(D)(3), z_6(D)(9)>

[CHECK] Found def edge 1 in w_2 = PHI <w_1(5), 10(10)>

[AFTER NORMALIZATION -- [USE]:
p = w_2;
is guarded by :

y_7(D) != 0
(.OR.)
x_4(D) != 0

[AFTER NORMALIZATION -- [DEF]:
w_2 = PHI <w_1(5), 10(10)>
is guarded by :

y_7(D) != 0


[CHECK]: Found unguarded use: p = w_2;

void
void foo(int, int, int) (int x, int y, int z)
{
  int w;
  int _8;

  <bb 2>:
  if (x_4(D) != 0)
    goto <bb 9>;
  else
    goto <bb 3>;

  <bb 9>:
  goto <bb 4>;

  <bb 3>:

  <bb 4>:
  # w_1 = PHI <w_5(D)(3), z_6(D)(9)>
  if (y_7(D) != 0)
    goto <bb 10>;
  else
    goto <bb 5>;

  <bb 10>:
  goto <bb 6>;

  <bb 5>:

  <bb 6>:
  # w_2 = PHI <w_1(5), 10(10)>
  _8 = x_4(D) | y_7(D);
  if (_8 != 0)
    goto <bb 7>;
  else
    goto <bb 11>;

  <bb 11>:
  goto <bb 8>;

  <bb 7>:
  p = w_2;

  <bb 8>:
  return;

}


uninit analysis correctly detects two defining edges but one of the edges
(src=bb 9, dest=bb 4) flows into the control dependence root (bb 6).  Since
this edge can not be reached downwards from the CD root, it is not considered
when reconstructing the predicate chain that guards the definition of w_2.  As
a result, an incomplete def predicate chain is computed and a warning is
emitted.

If instead the control dependence root was bb 2 then the aforementioned edge
would not get discarded (because the edge could be reached from bb 2) and so
the computed def predicate chain would be complete.

I have a patch that fixes this issue.


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

* [Bug middle-end/61112] Simple example triggers false-positive -Wmaybe-uninitialized warning
  2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
  2014-05-08 14:08 ` [Bug middle-end/61112] " patrick at parcs dot ath.cx
  2014-05-08 16:27 ` patrick at parcs dot ath.cx
@ 2021-03-29 19:54 ` cvs-commit at gcc dot gnu.org
  2021-03-29 20:03 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-29 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:77093a75ca4f3a0d6d9ca77ca8905b77695a2599

commit r11-7896-g77093a75ca4f3a0d6d9ca77ca8905b77695a2599
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon Mar 29 13:52:53 2021 -0600

    PR tree-optimization/61112 - repeated conditional triggers false positive
-Wmaybe-uninitialized

    gcc/testsuite/ChangeLog:
            PR tree-optimization/61112
            * gcc.dg/uninit-pr61112.c: New test.

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

* [Bug middle-end/61112] Simple example triggers false-positive -Wmaybe-uninitialized warning
  2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
                   ` (2 preceding siblings ...)
  2021-03-29 19:54 ` cvs-commit at gcc dot gnu.org
@ 2021-03-29 20:03 ` msebor at gcc dot gnu.org
  2021-03-30 16:42 ` manu at gcc dot gnu.org
  2021-11-30 14:44 ` aldyh at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-29 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=99756
   Last reconfirmed|2019-03-03 00:00:00         |2021-3-29
      Known to work|6.1.0                       |
      Known to fail|                            |10.2.0, 11.0, 4.9.4, 5.5.0,
                   |                            |6.4.0, 7.2.0, 8.3.0, 9.1.0

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
I've added both the passing test case from comment #0 and the still failing
test case from comment #5 to the test suite and xfailed the latter (thus
reconfirming for GCC 11).  Without any further analysis, the comment #5 test
case also looks similar to pr99756.

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

* [Bug middle-end/61112] Simple example triggers false-positive -Wmaybe-uninitialized warning
  2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
                   ` (3 preceding siblings ...)
  2021-03-29 20:03 ` msebor at gcc dot gnu.org
@ 2021-03-30 16:42 ` manu at gcc dot gnu.org
  2021-11-30 14:44 ` aldyh at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu.org @ 2021-03-30 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #8)
> I've added both the passing test case from comment #0 and the still failing
> test case from comment #5 to the test suite and xfailed the latter (thus
> reconfirming for GCC 11).  Without any further analysis, the comment #5 test
> case also looks similar to pr99756.

I think the '||' is a red-herring or insufficient to explain the PR. The
following also warns:

int p;
void foo (int x, int y, int z, int a)
{
  int w;
  if (x)
    w = z;
  if (y)
    w = 10;
  if (a)
    w = 67;
  if (x)
    p = w;
}

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

* [Bug middle-end/61112] Simple example triggers false-positive -Wmaybe-uninitialized warning
  2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
                   ` (4 preceding siblings ...)
  2021-03-30 16:42 ` manu at gcc dot gnu.org
@ 2021-11-30 14:44 ` aldyh at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: aldyh at gcc dot gnu.org @ 2021-11-30 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #10 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
the snippets in comment 1, 5, and 9 no longer warn on trunk.

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

end of thread, other threads:[~2021-11-30 14:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08 14:07 [Bug middle-end/61112] New: Simple example triggers false-positive -Wmaybe-uninitialized warning patrick at parcs dot ath.cx
2014-05-08 14:08 ` [Bug middle-end/61112] " patrick at parcs dot ath.cx
2014-05-08 16:27 ` patrick at parcs dot ath.cx
2021-03-29 19:54 ` cvs-commit at gcc dot gnu.org
2021-03-29 20:03 ` msebor at gcc dot gnu.org
2021-03-30 16:42 ` manu at gcc dot gnu.org
2021-11-30 14:44 ` aldyh 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).