This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
shadowed "for" scope variables not throwing up a warning (gcc 3.1.1/cygwin)
- From: "Dylan Cuthbert" <dylan at q-games dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 5 Aug 2002 20:07:38 +0900
- Subject: shadowed "for" scope variables not throwing up a warning (gcc 3.1.1/cygwin)
- Newsgroups: gmane.comp.gcc.devel
for ( int i = 0; i < 10; i++ )
{
int i = 10; <===== shadowing the i variable
printf( "%d\n", i );
}
To my understanding, the "int i" in the for statement is within the scope of
the following curly brackets?
If this isn't an error (ie. there is a special "mini" scope created around
the for statement's scope), then it *definitely* *definitely* (pretty
please) should throw up a warning. I just spent a while looking at some
code before realising it was something as silly as this.
Regards
---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com
P2P internet radio - http://www.peercast.org