comiler warnings
Tom Emerson
tree@basistech.com
Sun Dec 25 14:40:00 GMT 2005
Dima Sorkin writes:
> Hi.
> Look at the following peace of code:
> for(unsigned i;i<10;++i){
> do something with "i";
> }
>
> gcc-3.3.6 under slackware linux:
>
> When compiling in debug mode (-g), no warnings.
> When compiling with optimization (-O2), it warns
> that "i" will be used unitialized in the loop.
>
> Why does compiler behave this way ?
Presumably because with -g the uninitialized variable check isn't
performed. The behavior of that code is undefined: you really want to
be initializing that loop variable.
-tree
--
Tom Emerson Basis Technology Corp.
Software Architect http://www.basistech.com
"You can't fake quality any more than you can fake a good meal." (W.S.B.)
More information about the Gcc-help
mailing list