http://llvm.org/bugs/show_bug.cgi?id=21481
Bug ID: 21481
Summary: Overload is incorrectly ignored
Product: clang
Version: 3.5
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Created attachment 13290
--> http://llvm.org/bugs/attachment.cgi?id=13290&action=edit
Test case failing with clang-3.5. Compile with -std=c++11
Under certain conditions clang ignores a function overload due to a
substitution failure although substitution should succeed. Suppose you have
template<class... T>
struct Foo
{};
template<class T0, class... T>
struct Foo<T0, T...>
{
typedef T0 First;
};
and two overloaded functions selected using enable_if
template<class C, class... T,
typename std::enable_if<std::is_same<C, Foo<> >::value, int>::type =0>
int bar()
{
return 0;
}
template<class C, class... T,
typename std::enable_if<!(std::is_same<C, Foo<> >::value), int>::type =0>
auto bar()
-> decltype(typename C::First()) // This should be OK by SFINAE
{
return 0;
}
Then substitution of C::First should work for C=Foo<int>. However clang rejects
bar<Foo<int>, char>(). Surprisingly the overload is used if the additional char
parameter is omitted or if an instance of Foo<int> is created in main().
A test case that fails with clang-3.5 is attached. Notice that the variadic
templates seem to be necessary to trigger the problem.
Side note: gcc-4.8 accepts the code.
--
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