http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56574
Thiago Macieira <thiago at kde dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |thiago at kde dot org
--- Comment #3 from Thiago Macieira <thiago at kde dot org> 2013-03-08 21:11:19
UTC ---
Looking at the code that GCC generated (4.7.2 from Fedora and similarly with
pristine 4.8 trunk@196249):
%edi = flag; %eax = value
11 testl %edi, %edi
12 je .L12
.L12 is the call to get_value() is placed
13 .L2:
14 testl %edi, %edi
15 sete %dl
16 testl %eax, %eax
Here, EAX might be uninitialised
17 setne %al
18 testb %dl, %al
19 jne .L3
.L3 is an infinite loop
20 testb %dl, %dl
21 jne .L8
.L8 is the function exit (the loop break)
fall-through is an infinite loop
In other words, the warning is true: the generated code *is* using an
uninitialised variable.
The question is whether that is acceptable.
In order for EAX to be uninitialised, we must not have jumped to .L12. Since
the JE jump on line 12 was not taken, SETE must have set DL to 0 on line 15.
Then we compare AL to DL on line 18: as DL is zero, the result of the
comparison is ZF, whichever the value of AL might be. That means the JNZ jump
on line 19 is not taken.
The code will then proceed to the infinite loop.
Conclusion: it's just a bogus warning. It is correct from the point of view of
the assembly code that was generated, but the uninitialised value is never used
in any decisions.