https://llvm.org/bugs/show_bug.cgi?id=24076
Bug ID: 24076
Summary: Clang compiles a substitution failed template with
default parameter
Product: clang
Version: 3.6
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
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
}
--
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