This is the mail archive of the gcc-bugs@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]

-Wshadow flag / C++ issue


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



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