The following simple test program when compiled with -Wshadow produces no output. I'd expect to get warnings for both the x and y declaration in class B. class A { static int x; int y; }; class B : public A { static int x; int y; }; int main() { B a; return 0; } If this is intentional, perhaps another -W flag is appropriate. I spent about an hour trying to figure out why an app broke when I change a static class member declared in a class's header to instead be an anonymous global in that class's source file, and it was because all of the source file's references to the variable after the change went to a parent class variable of the same name and type rather than the global.
I agree this would be useful, I've had problems with such shadowing when moving members higher in inheritance hierarchies and accidentally missing occurrences in some derived classes. 4.2 is unmaintained now, but current releases don't warn either.
Confirmed on trunk: https://godbolt.org/z/jL0ony
(In reply to krux from comment #2) > Confirmed on trunk: https://godbolt.org/z/jL0ony OK, updating "Last reconfirmed" date then
Dup of bug 12341. *** This bug has been marked as a duplicate of bug 12341 ***