This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: int initialization bug ?
I <mveksler@technion.ac.il> wrote:
> Pina Colada dude <pinacolada@margaritaville.com> wrote:
[snip]
> >
> > for(int k=0;k<255;k++)
> > {
> > ....
> > }
>
> According to ISO/ANSI C++ k gets out of scope here (k is defined only
> in the 'for' loop.)
>
> > for(int m=0;m<k;m++)
[snip]
> As I know, egcs-1.1.2 complaints but still compiles the code.
> But, gcc-2.95 fails to compile this code.
> To circumvent this, if you must, you can try to use the "-fno-for-scope"
> flag (your code will not be portable with it!).
>
I forgot to mention the '-fpermissive' flag that will make gcc-2.95
complain, but succeed to complete the compilation (as egcs-1.1.2 did).
Michael