https://bugs.llvm.org/show_bug.cgi?id=42213
Bug ID: 42213
Summary: Invalid template parameter
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
My clang is 9.0.0, and the code is:
template < bool, class > struct A {};
template < class, int > void f () {};
template < class T, int >
decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
struct B {};
int main ()
{
f < B, 0 >;
return 0;
}
clang accepts the code, but icc, gcc, and msvc all reject it:
gcc:
<source>:5:56: error: wrong number of template arguments (1, should be 2)
5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
| ^
<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'
2 | template < bool, class > struct A {};
| ^
<source>:5:40: error: expected nested-name-specifier before 'A'
5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
| ^
<source>:5:56: error: wrong number of template arguments (1, should be 2)
5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
| ^
<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'
2 | template < bool, class > struct A {};
| ^
<source>:5:56: error: wrong number of template arguments (1, should be 2)
5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
| ^
<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'
2 | template < bool, class > struct A {};
| ^
<source>:5:56: error: wrong number of template arguments (1, should be 2)
5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
| ^
<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'
2 | template < bool, class > struct A {};
| ^
<source>:5:42: error: expected ',' or '...' before '<' token
5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
| ^
Compiler returned: 1
icc:
<source>(5): error: a parameter is not allowed
decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};
^
compilation aborted for <source> (code 2)
Compiler returned: 2
msvc:
example.cpp
<source>(5): error C2975: 'unnamed-parameter': invalid template argument for
'A', expected compile-time constant expression
<source>(2): note: see declaration of 'unnamed-parameter'
<source>(5): error C2039: 'type': is not a member of 'A<false,int>'
<source>(5): note: see declaration of 'A<false,int>'
<source>(5): error C4430: missing type specifier - int assumed. Note: C++ does
not support default-int
<source>(11): warning C4551: function call missing argument list
Compiler returned: 2
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs