This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++: -Wshadow violates the ISO C++ scoping rules
- To: gcc-bugs at gcc dot gnu dot org
- Subject: C++: -Wshadow violates the ISO C++ scoping rules
- From: Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>
- Date: Thu, 27 Jan 2000 17:43:08 +0100 (MET)
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/