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: unassig...@gcc.gnu.org

        ReportedBy: rgue...@gcc.gnu.org

                CC: xinlian...@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.

Reply via email to