http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60025
Bug ID: 60025 Summary: Static member of class not found if class name == namespace name it's defined in Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ppilar11 at gmail dot com Consider this definition: namespace Foo { int x; class Foo { public: static int x; }; int Foo::x; } and test code in which it's used: int main() { using namespace Foo; Foo::x; return 0; } Both gcc 4.7.2 and gcc 4.8.1 accept the above code even though Foo::x is ambiguous: could be either a global variable in namespace Foo or static member of class Foo. Visual C++ 2013 rejects the code with "error C2872: 'Foo' : ambiguous symbol could be 'Foo' or 'Foo::Foo'", gcc simply resolves Foo::x to global variable x. If I comment out the global variable x from namespace definition then both gcc 4.7.2 and gcc 4.8.1 reject the code with "error: 'x' is not a member of 'Foo'", so they fail to find the static member of class Foo unless I qualify it as Foo::Foo::x (which should not be necessary due to "using" directive).