[LLVMbugs] [Bug 7247] New: Global templates shouldn't make member template functions ambiguous

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 28 10:13:01 PDT 2010


           Summary: Global templates shouldn't make member template
                    functions ambiguous
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jyasskin at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

template<typename T> struct set{};
template<typename T> struct trait { typedef const T& type; };
struct Value {
    template<typename T>
    void set(typename trait<T>::type value) {
void foo() {
    Value v;

should be valid. As it is, clang complains:

test.cc:10:7: error: lookup of 'set' in member access expression is ambiguous
test.cc:5:10: note: lookup in the object type 'Value' refers here
    void set(typename trait<T>::type value) {
test.cc:1:29: note: lookup from the current scope refers here
template<typename T> struct set{};

That is, clang should ignore the second half of basic.lookup.classref para 1,
where, after finding the name the user intended, it's also required to try to
find a template the user didn't intend in order to break the compile. Gcc
ignores this problem while Comeau only emits a warning.

I've filed a national-body comment to try to get this officially fixed in
C++0x. A similar problem with destructors was fixed in issue 305:

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