[LLVMbugs] [Bug 22192] New: When printing an ambiguous-overload error that causes a substitution failure, print the candidates
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jan 10 23:25:33 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22192
Bug ID: 22192
Summary: When printing an ambiguous-overload error that causes
a substitution failure, print the candidates
Product: clang
Version: 3.5
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: zeratul976 at hotmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Consider the following (invalid) code:
void foo(double);
void foo(long);
template <typename T>
decltype(foo(T())) bar(T);
int main()
{
bar(3);
}
The error message clang prints for this is:
test.cpp:9:5: error: no matching function for call to 'bar'
bar(3);
^~~
test.cpp:5:20: note: candidate template ignored: substitution failure [with
T = int]: call to 'foo' is ambiguous
decltype(foo(T())) bar(T);
~~~ ^
The error message talks about an overload ambiguity, but doesn't print the
candidates.
Compare the error given by gcc:
test.cpp: In function 'int main()':
test.cpp:9:10: error: no matching function for call to 'bar(int)'
bar(3);
^
test.cpp:9:10: note: candidate is:
test.cpp:5:20: note: template<class T> decltype (foo(T())) bar(T)
decltype(foo(T())) bar(T);
^
test.cpp:5:20: note: template argument deduction/substitution failed:
test.cpp: In substitution of 'template<class T> decltype (foo(T())) bar(T)
[with T = int]':
test.cpp:9:10: required from here
test.cpp:5:17: error: call of overloaded 'foo(int)' is ambiguous
decltype(foo(T())) bar(T);
^
test.cpp:5:17: note: candidates are:
test.cpp:1:6: note: void foo(double)
void foo(double);
^
test.cpp:2:6: note: void foo(long int)
void foo(long);
^
which lists the candidates.
I think it's important to list the candidates, so the user can understand the
error and fix the ambiguity more efficiently.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150111/a872dcc0/attachment.html>
More information about the llvm-bugs
mailing list