[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


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

           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;
    v.set<double>(3.2);
}

should be valid. As it is, clang complains:

test.cc:10:7: error: lookup of 'set' in member access expression is ambiguous
    v.set<double>(3.2);
      ^
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:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#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