9400 – [3.2 regression] Warning -Wshadow warns of shadowed declaration of THIS in local classes. (original) (raw)
When compiling the test code with "gcc -c -Wshadow", the following warning is emitted:
test.cpp: In constructor A::a1()::B::B()': test.cpp:5: warning: declaration of this' shadows a parameter
test.cpp:3: warning: shadowed declaration is here
Note that this warning is not emitted if I don't declare a constructor in the local class (as in A::a2())
I think the warning should always be suppressed if 'this' is involved since it it not a variable as such.
I've observed this behaviour in the gcc 3.3 prerelease snapshot from 2003-01-13 as well. I've also observed it on Linux and Solaris.
Release: GCC 3.1
How-To-Repeat: cat > test.cpp <<EOF struct A { void a1 () { struct B { B() {} }; } void a2 () { struct B { }; } }; EOF gcc -c -Wshadow test.cpp
Comment 2 Wolfgang Bangerth 2003-01-22 14:57:47 UTC
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. Indeed a funny error...
This used to not warn until 3.0, but does so with present
3.2, 3.3, and 3.4 CVS, so it's kind of a regression.
W:Comment 9 Joe Buck 2003-04-25 21🔞10 UTC
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for 3.3.