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



             Bug #: 56574

           Summary: False possibly uninitialized variable warning

    Classification: Unclassified

           Product: gcc

           Version: 4.7.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: mark.d.rus...@intel.com





The following code produces the warning,'value' may be used uninitialized:



int get_value(void);



void show_problem(int flag)

{

    int value;



    if (!flag)

        value = get_value();



    for (;;) {

        if (!flag && value)

            continue;



        if (!flag)

            break;

    }

}



The warning occurs only with -O1 and -O2 optimization. -O0 and -O3 and higher

do not. It also occurs with many versions. I have gotten the same result with

the following versions of gcc:



i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]

gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)

gcc (GCC) 4.7.0 20120507 (Red Hat 4.7.0-5)



Interestingly, the much larger function that originally displayed the problem

does not generate a warning with the 4.7.0 compiler, but does on the others.

Reply via email to