This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: comiler warnings


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.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]