public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56654] New: uninit warning behaves erratically
@ 2013-03-18 13:38 rguenth at gcc dot gnu.org
  2014-09-11 22:14 ` [Bug tree-optimization/56654] " manu at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-18 13:38 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56654
           Summary: uninit warning behaves erratically
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org
                CC: xinliangli@gmail.com


For c-c++-common/uninit-17.c we currently expect the uninit use at:

static void bar(int a, int *ptr)
{
  do
  {
    int b;   /* { dg-message "declared" } */
    if (b < 40) {
      ptr[0] = b;
    }
    b += 1; /* { dg-warning "may be used uninitialized" } */
    ptr++;
  }
  while (--a != 0);
}

where I would expect it at the if stmt.  Now, when I exchange the late
DOM and the late VRP passes I instead get the warning two lines earlier
(inside the guarded BB).  But there is no change in the IL:

> diff -u a/uninit-17.c.131t.uninit1 b/uninit-17.c.131t.uninit1 
--- a/uninit-17.c.131t.uninit1  2013-03-18 14:27:16.677116283 +0100
+++ b/uninit-17.c.131t.uninit1  2013-03-18 14:26:58.956922876 +0100
@@ -3,7 +3,13 @@

 [WORKLIST]: add to initial list: b_5 = PHI <b_13(D)(2), b_7(6)>
 [CHECK]: examining phi: b_5 = PHI <b_13(D)(2), b_7(6)>
-[CHECK]: Found unguarded use: b_7 = b_5 + 1;
+
+Use in stmt *ptr_6 = b_5;
+is guarded by :
+if (b_5 <= 39)
+
+[CHECK] Found def edge 1 in b_5 = PHI <b_13(D)(2), b_7(6)>
+[CHECK]: Found unguarded use: *ptr_6 = b_5;
 void foobar(int, int*) (int a, int * ptr)
 {
   int b;

the only difference is in the order of b_5 immediate uses.

That is, find_uninit_use should impose an ordering when walking over
immediate uses - for example visit the most dominating use first.


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

end of thread, other threads:[~2022-08-30  7:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-18 13:38 [Bug tree-optimization/56654] New: uninit warning behaves erratically rguenth at gcc dot gnu.org
2014-09-11 22:14 ` [Bug tree-optimization/56654] " manu at gcc dot gnu.org
2021-03-26 16:41 ` [Bug tree-optimization/56654] uninit warning behaves erratically (always executed block, "is" vs "may", order when walking uses) msebor at gcc dot gnu.org
2022-08-29 14:09 ` rguenth at gcc dot gnu.org
2022-08-30  7:33 ` cvs-commit at gcc dot gnu.org
2022-08-30  7:33 ` rguenth 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).