This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/18530] [4.0 regression] Bogus warnings about shadowed variables __ct, __dt
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Nov 2004 12:08:55 -0000
- Subject: [Bug c++/18530] [4.0 regression] Bogus warnings about shadowed variables __ct, __dt
- References: <20041117161141.18530.martin@mpa-garching.mpg.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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