http://llvm.org/bugs/show_bug.cgi?id=22435
Bug ID: 22435
Summary: Partial ordering finds candidate to be more
specialized despite contrary P/A pair
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Clang does not produce a diagnostic (where GCC does) for the following where
the call in "bar" is expected to be ill-formed as per N4296 13.3.3/2; there is
no better function between (A) and (B), but Clang chooses (B).
### SOURCE (<stdin>):
>>
template <typename T, typename U>
void foo(void (*)(T), const U &); // (A)
template <typename T, typename U>
bool foo(void (*)(T &), U &); // (B)
void bar(const int x) {
bool b = foo<char>(0, x);
}
<<
In particular, replacing the templates with their corresponding instantiations
as non-template functions, i.e.,
void foo(void (*)(char), const int &)
and
bool foo(void (*)(char &), const int &)
shows that Clang agrees that the call is ambiguous aside from template-related
considerations.
Furthermore, the choice of (B) cannot be justified by bullet 1.7 in 13.3.3
since, following from 14.8.2.4/10, (B) is not more specialized than (A) due to
the following:
When the types of the second parameter are considered with (A) as the argument
template, bullet 9.2 in 14.8.2.4 [temp.deduct.partial] applies and the
corresponding type from (B), the parameter template, is not considered to be at
least as specialized as the one from the argument template (A).
### COMPILER INVOCATION:
clang -cc1 -Wall -Wextra -Wno-unused -pedantic-errors -x c++ -
### ACTUAL OUTPUT:
(Clean compile)
### EXPECTED OUTPUT:
<stdin>:8:13: error: call to 'foo' is ambiguous
bool b = foo<char>(0, x);
^~~~~~~~~
<stdin>:2:6: note: candidate function [with T = char, U = int]
void foo(void (*)(T), const U &); // (A)
^
<stdin>:5:6: note: candidate function [with T = char, U = const int]
bool foo(void (*)(T &), U &); // (B)
^
1 error generated.
### COMPILER VERSION INFO:
clang version 3.7.0 (trunk 227802)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Candidate multilib: .;@m64
Selected multilib: .;@m64
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs