This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
-Wshadow flag / C++ issue
- To: <egcs-bugs at egcs dot cygnus dot com>
- Subject: -Wshadow flag / C++ issue
- From: "Emmanuel Blot" <eblot at sablet dot grenoble dot hp dot com>
- Date: Tue, 11 May 1999 14:50:03 +0200
Consider the following C++ code fragment :
void func()
{
for ( int i=0; i < 2; ++i )
{
cout << "1st loop" << endl;
}
for ( int i=0; i < 4; ++i ) // line number 228 of the complete source
file
{
cout << "2nd loop" << endl;
}
}
Compiling with the "-Wshadow" flag yields the following warning, which is
wrong according to the new C++ "for scope".
D:/Projets/nlc/ControlLogic/src/test.cpp:228: warning: declaration of `i'
shadows previous local
-----------------------------------------------------------------------
Emmanuel BLOT +33 6 81 03 02 97 - Grenoble, France