[Bug c++/87035] Can't shadow global const int with unnamed enum in class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87035 --- Comment #4 from Nicolas Lesser --- Nice, thank you!
[Bug c++/87035] Can't shadow global const int with unnamed enum in class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87035 --- Comment #5 from Andrew Pinski --- [basic.scope.class] p2: "A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule."
[Bug c++/87035] Can't shadow global const int with unnamed enum in class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87035 --- Comment #3 from Andrew Pinski --- (In reply to Nicolas Lesser from comment #2) > Huh, interesting. TIL. Where's that rule in the standard? Because I can't > find it in [class.mem]. Is it somewhere else or did I just overlook it? C++98 paragraph numbers: See 3.3.6/1 [...] 2) A name N used in a class S shall refer to the same declaration in its context and when reevaluated in the completed scope of S. No diagnostic is required for a violation of this rule. I think that is the same as [basic.scope.class].
[Bug c++/87035] Can't shadow global const int with unnamed enum in class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87035 --- Comment #2 from Nicolas Lesser --- Huh, interesting. TIL. Where's that rule in the standard? Because I can't find it in [class.mem]. Is it somewhere else or did I just overlook it?
[Bug c++/87035] Can't shadow global const int with unnamed enum in class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87035 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Andrew Pinski --- Actually no this is invalid code at least according to the standard. Since N definition has to be the same when used and at the end of the scope. In this case, you have a different one. The error message is very clear about that too: t8.cc:5:10: error: declaration of ‘N’ [-fpermissive] enum { N }; // fails, redeclaration ^ t8.cc:1:11: error: changes meaning of ‘N’ from ‘const int N’ [-fpermissive] const int N = 5; ^ Maybe just the use of N is not in the error message.