http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52771
Bug #: 52771 Summary: name found in contexts not referring to the same entity should not compile Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: ch...@gcc.gnu.org The following code compiles without error: struct foo { int A() { return 1;} }; int main() { foo xo ; foo *px = &xo; struct foo { int A() { return 0;} }; return px->foo::A(); } from 3.4.5: "If the name is found in both contexts, the class-name-or-namespace-name shall refer to the same entity". since "the class-name-or-namespace-name following the . or -> operator is looked up both in the context of the entire postfix-expression and in the scope of the class of the object expression" Then foo() can be both local or global, not the same entity, and therefore invalid.