[Bug c++/52771] New: name found in contexts not referring to the same entity should not compile

chrbr at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 29 13:24:00 GMT 2012


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: unassigned@gcc.gnu.org
        ReportedBy: chrbr@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.



More information about the Gcc-bugs mailing list