struct A
{
enum E
{
FIRST,
SECOND
};
};
struct B
{
typedef A::E E;
};
int main()
{
B::E e0 = A::FIRST;//OK (this case is clear for me)
B::E e1 = A::E::FIRST;//OK (this case is clear for me as well)
B::E e2 = B::FIRST;//Compile Error: FIRST is not member of B (Why isn't this allowed? Don't we lose meaning of typedef of enums in this case?)
B::E e3 = B::E::FIRST;//Error of compiler (If there were no bug in visual studio 2005 compiler, would this code work?)
return 0;
}
P.S. The question in code.
Update: Actually the bug is fixed in VS2010.
After adding the missing semicolon in
B::E e3 = B::E::FIRST, the following holds:In C++03, only the first line (
B::E e0 = A::FIRST;) is correct, the other three are errors:In C++0x, only the second line (
B::E e2 = B::FIRST;) is an error (FIRST is still not a member of B!), the other three are correct.Not an answer to the “why?”, just pointing out that there are two different issues at hand. The rationale for the issue that affects e1 and e3 is probably explained in the C++0x working papers.
The change was to the first sentence of 3.4.3[basic.lookup.qual]/1 which now says
But it used to say