On Wed, November 19, 2008 11:59 am, argiris kirtzidis wrote:
> Douglas Gregor wrote:
>>
>> That isn't the way I read C++03 3.4.3p1. The second sentence says:
>>
>> "During the lookup for a name preceding the::scope resolution
>> operator, object, function, and enumerator names are ignored."
>>
>> An enumeration name is not an operator, object, function, or
>> enumerator name, so we shouldn't be ignoring them.
>
> I think you are right but let's be absolutely certain about this; you
> brought up GCC as the compiler that gets it right, but GCC also ignores
> enumerations:
>
> namespace A {
> int x;
> }
>
> void f() {
> enum A {};
> A::x = 0;
> }
>
> GCC compiles it without errors.
Hrm, you're right. That's a bit disturbing. This, of course, is the fun one:
#include <iostream>
namespace A {
int x = 17;
}
int main() {
enum A { x = 42 };
std::cout << A::x << '\n';
}
With GCC 4.4 (which supports scoped enums in its C++0x mode), we get "17"
in C++98 mode and "42" in C++0x mode. I'm pretty certain the code is
ill-formed in C++98/03, but it's time for me to go ask in a larger forum.
- Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits