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]

C++: -Wshadow violates the ISO C++ scoping rules


The following snippet shows a bug in the -Wshadow as for as the ISO C++
scoping rules are concerned:

  int main() {
    for(int i=1; i < 3; i++);
    for(int i=1; i < 3; i++);
    }

  nunki% gcc -ansi -Wshadow y.cc
  y.cc: In function `int main ()':
  y.cc:3: warning: declaration of `i' shadows previous local

This effectively renders -Wshadow unusable for large classes of C++ code.

Tested with GCC 2.95.2 and current CVS sources.

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/


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