On 04/05/2012 02:28 PM, Nadav Har'El wrote:
> I tried to avoid the details, but since you asked, here they are.
> Imagine code like this:
>
>       extern int flag;
>
>       ...
>
>       void f(){
>               int i;
>               if (flag)
>                       i=0;    
>               g();
>               if (flag)
>                       dosomething(i);
>       }
>
> Now, the compiler (starting a certain version of GCC, with high enough
> optimization setting) will warn that i may be used without being set.
> Why? After all, it is only used if flag is true, and in that case, i
> *was* set. Well, the problem is that the compiler can't know that flag
> isn't changed in the middle of the function call, perhaps by another
> thread. Perhaps in the call to g(). But *I* know that it can't - this
> program is single-threaded, g() does nothing to the flag, and in fact
> "flag" is never changed after initialization.
>
Yes, the warning's name was abbreviated for the sake of clarity to
include the most common case. The complete warning message is:
"Variable used before being initialized, or a missed optimization
opportunity"

Shachar

-- 
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com

_______________________________________________
Linux-il mailing list
[email protected]
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to