<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Partial ordering finds candidate to be more specialized despite contrary P/A pair"
href="http://llvm.org/bugs/show_bug.cgi?id=22435">22435</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Partial ordering finds candidate to be more specialized despite contrary P/A pair
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hstong@ca.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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>):
<span class="quote">>></span >
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>