[llvm-bugs] [Bug 26983] New: Overload resolution partial ordering for variadic function template with dependent type
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 17 19:10:07 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=26983
Bug ID: 26983
Summary: Overload resolution partial ordering for variadic
function template with dependent type
Product: clang
Version: 3.8
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: bobmoretti at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
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 https://llvm.org/bugs/show_bug.cgi?id=14372)
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] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1395
[2]
http://stackoverflow.com/questions/36051645/is-a-c11-variadic-function-template-overload-with-a-dependent-type-ambiguous
--
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/20160318/fdb7bfc8/attachment.html>
More information about the llvm-bugs
mailing list