[YBA] kernel compile errors with GCC >= 4.6

[YBA] kernel compile errors with GCC >= 4.6

Shachar Shemesh shachar at shemesh.biz
Fri Apr 6 08:03:08 IDT 2012


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20120406/954b7e55/attachment-0001.html>


More information about the Linux-il mailing list