[LLVMbugs] [Bug 12268] New: Ambiguous class member lookup

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 14 10:56:44 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12268

             Bug #: 12268
           Summary: Ambiguous class member lookup
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: binocs38149 at mypacks.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8208
  --> http://llvm.org/bugs/attachment.cgi?id=8208
Test case source code

For the attached case we are receiving a compile error, which we have been
advised should not be an error under C++11:

% clang -c -std=c++11 clang-base-test2.cxx
clang-base-test2.cxx:16:5: error: lookup of 'X' in member access expression is
ambiguous
        b->X::f(); // ## What happens here?
           ^
clang-base-test2.cxx:4:26: note: lookup in the object type 'B' refers here
struct B : A { typedef A X; };
                         ^
clang-base-test2.cxx:5:26: note: lookup from the current scope refers here
struct D : C { typedef C X;   void g(); };
                         ^
1 error generated.

This is with Apple clang version 4.0 (tags/Apple/clang-418.0.46) (based on LLVM
3.1svn).  We see the same issue with Apple clang 3.0 based on LLVM 3.0svn,
using -std=c++0x.

========

The advice we received follows:

The relevant rule comes from [basic.lookup.classref].  In C++2003, it says:

"If the id-expression in a class member access is a qualified-id of the form
class-name-or-namespace-name::...
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. [...]   If the name is found in both contexts,
the class-name-or-namespace-name shall refer to the same entity."

But in the C++2011 FDIS (Final Draft International Standard) it says:

"the class-name-or-namespace-name following the . or -> operator is first
looked up in the class of the object expression and the name, if found, is
used. Otherwise it is looked up in the context of the entire
postfix-expression."

So it's not really an error anymore.  To see when and why it changed, we can
search for the same section number (3.4.5) in the list of defect reports:

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3294.html

... and there we find a handful of issues, one of which is core issue 1111:
"Remove dual-scope lookup of member template names", which contains the actual
delta.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list