This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]