[LLVMbugs] [Bug 6850] New: Unhelpful diagnostic when template calls later-declared function not found by ADL

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 15 20:53:02 CDT 2010


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

           Summary: Unhelpful diagnostic when template calls
                    later-declared function not found by ADL
           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


When a template calls another function, the target of the call has to be
declared before the implementation, unless it's found by ADL, in which case it
can be declared later. Clang's error message doesn't provide either of those
hints, and it should. This has confused at least one clang early adopter inside
of google.


$ cat test.cc
#include <utility>
using std::pair;

void my_template(int) {}

#ifdef WORK
template<typename T, typename U>
void my_template(const pair<T, U>& p);
#endif

template<typename T>
void call_template(const T& t) {
    my_template(t);
}

#ifdef WORK2
namespace std {
#endif
template<typename T, typename U>
void my_template(const pair<T, U>& p) {
}
#ifdef WORK2
}
#endif

void foo() {
    pair<int, int> p(3, 4);
    call_template(p);
}
$ clang++  -c test.cc
test.cc:13:5: error: no matching function for call to 'my_template'
    my_template(t);
    ^~~~~~~~~~~
test.cc:28:5: note: in instantiation of function template specialization
'call_template<std::pair<int, int> >' requested here
    call_template(p);
    ^
test.cc:4:6: note: candidate function not viable: no known conversion from
'std::pair<int, int> const' to 'int' for 1st argument
void my_template(int) {}
     ^
1 error generated.
$ clang++  -c test.cc -DWORK
$ clang++  -c test.cc -DWORK2
$

-- 
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 LLVMbugs mailing list