<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 --- - Overload resolution partial ordering for variadic function template with dependent type"
href="https://llvm.org/bugs/show_bug.cgi?id=26983">26983</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Overload resolution partial ordering for variadic function template with dependent type
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bobmoretti@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>clang++ compiles the following code cleanly with -std=c++11:
template <typename T>
int add(T val)
{
return val;
}
template <typename FirstTypeT, typename... RestT>
int add(FirstTypeT first_value, RestT... rest)
{
return first_value + add<RestT...>(rest...);
}
int main(void)
{
return add(12, 12, 12);
}
But the following similar code results in an ambiguous overload error:
struct Foo
{
using SomeType = int;
};
template <typename T>
int add(typename T::SomeType val)
{
return val;
}
template <typename FirstT, typename... RestT>
int add(typename FirstT::SomeType first_value, typename RestT::SomeType...
rest)
{
return first_value + add<RestT...>(rest...);
}
int main(void)
{
return add<Foo, Foo, Foo>(12, 12, 12);
}
According to the standard, both of these should be rejected. However, it looks
like clang is intended to implement the recommendation for core issue #1395
[1](for example, see <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED --- - Partial ordering of variadic function template"
href="show_bug.cgi?id=14372">https://llvm.org/bugs/show_bug.cgi?id=14372</a>)
If clang is attempting to follow the recommendation, I think it should allow
both examples, and not just the first one.
Credit to Columbo on stackoverflow.com for confirming that this is likely an
issue. [2]
[1] <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1395">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1395</a>
[2]
<a href="http://stackoverflow.com/questions/36051645/is-a-c11-variadic-function-template-overload-with-a-dependent-type-ambiguous">http://stackoverflow.com/questions/36051645/is-a-c11-variadic-function-template-overload-with-a-dependent-type-ambiguous</a></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>