This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: comiler warnings
- From: Tom Emerson <tree at basistech dot com>
- To: Dima Sorkin <dsorkin at techunix dot technion dot ac dot il>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 25 Dec 2005 09:40:14 -0500
- Subject: Re: comiler warnings
- References: <1135518059.43aea16bbb598@webmail.technion.ac.il>
- Reply-to: tree at basistech dot com
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.)