<html>
<head>
<base href="https://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 --- - Clang compiles a substitution failed template with default parameter" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24076&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=aNW03NXp2J_a5wzBVIxVlPdSxnps47oiFQbridB3Rjk&s=vaCnWqY5W3yC3xsNfl0fnt0yc1VDutsEJcy8Ra8wAfw&e=">24076</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang compiles a substitution failed template with default parameter
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>antoshkka@gmail.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>If substitution of a single matching function failed, clang does not fail
compilation:
template <class ...>
using void_t = void;
template <class T>
T declval();
template <class T, class = void_t< decltype(declval<T>() + 1) > >
void foo(T) {}
struct s{};
int main() {
foo(s{}); // must fail compilation, but does not
}
For example GCC fails with the following messages:
main.cpp:13:12: error: no matching function for call to 'foo(s)'
foo(s{}); // must fail compilation, but does not
^
main.cpp:8:6: note: candidate: template<class T, class> void foo(T)
void foo(T) {}
^
main.cpp:8:6: note: template argument deduction/substitution failed:
main.cpp:7:58: error: no match for 'operator+' (operand types are 's' and
'int')
template <class T, class = void_t< decltype(declval<T>() + 1) > >
^
Exactly the same problem for classes:
template <class ...>
using void_t = void;
template <class T>
T declval();
template <class T, class = void_t< decltype(declval<T>() + 1) > >
struct foo {
foo(T) {};
};
struct s{};
int main() {
foo<s>(s{}); // must fail compilation, but does not
}</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>