------- Additional Comments From reichelt at gcc dot gnu dot org 2004-11-23 12:08 ------- Well, here's not a quote from the standard, but an example that illustrates why this is really shadowing:
============================================== struct A { typedef int X; void foo() { typedef int X; } // OK void bar() { typedef void X; } // OK }; ============================================== The typedefs in the functions are in nested scopes, so they just shadow the one in the outer (struct) scope. If the typedef in "bar" didn't shadow the one in line 7 we would get an error. The fact that the types accidentally coincide in the case of the function foo does not make the shadowing go away. I really think the warning should stay. If you've got a situation like the following, X might or might not be the same type inside foo as outside. In order to help users write portable code the warning should be there unconditionally, IMHO. ============================================== template<int> struct B; struct A { typedef B<4> X; void foo() { typedef B<sizeof(int)> X; } }; ============================================== -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18530