------- Comment #4 from manu at gcc dot gnu dot org  2007-08-15 15:21 -------
(In reply to comment #3)
> Is it really quite as 22456? That bug is about variable used for initializing
> itself, and really strange do-nothing code, while this one is straightforward
> use of unitialized variable:
> 
> int main (void)
> {
>   int i, foo;
>   for (i = 0; i < 10; i++)
>   {
>     if (i > 5)
>       foo = 8;
>     printf ("%d\n", foo); /* uninitialized foo is printed six times */
>   }
> }

I get ten times 8 printed. Roughly, an optimisation pass is assuming that the
initial value of foo is 8 (remember, undefined means we can assume whatever),
so foo is completely removed. Believe me, the optimisation is valid and
beneficial and in many situations the uninitialised value is never used (if we
were to warn, it will be a false positive). Unfortunately, this is not one of
these cases.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


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

Reply via email to