This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52771] New: name found in contexts not referring to the same entity should not compile
- From: "chrbr at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Mar 2012 13:23:25 +0000
- Subject: [Bug c++/52771] New: name found in contexts not referring to the same entity should not compile
- Auto-submitted: auto-generated
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.