[Bug c/56574] New: False possibly uninitialized variable warning

2013-03-08 Thread mark.d.rustad at intel dot com


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.


[Bug c/56574] False possibly uninitialized variable warning

2013-03-08 Thread mark.d.rustad at intel dot com


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



--- Comment #1 from Mark Rustad  2013-03-08 
19:24:27 UTC ---

It also appears that incorrect code is generated in cases where the warning is

produced. That incorrect code was referencing the uninitialized value. So the

warning is consistent with the code generated, but the code is wrong.