[PATCH] D42938: [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 2 10:29:10 PST 2018
vsapsai added a comment.
In https://reviews.llvm.org/D42938#1025151, @jkorous-apple wrote:
> Maybe a stupid idea but in case it makes sense to add these expression types could we also add integer template arguments?
The idea isn't stupid but I think it is already handled. For
template<int N> void f() {}
template<int N = 1000000 * 10240> void g() {}
void foo() {
f<1000000 * 10240>();
g();
}
I got errors
template-args.cpp:2:18: error: non-type template argument is not a constant expression
template<int N = 1000000 * 10240> void g() {}
^~~~~~~~~~~~~~~
template-args.cpp:2:26: note: value 10240000000 is outside the range of representable values of type 'int'
template<int N = 1000000 * 10240> void g() {}
^
template-args.cpp:5:5: error: no matching function for call to 'f'
f<1000000 * 10240>();
^~~~~~~~~~~~~~~~~~
template-args.cpp:1:22: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'N'
template<int N> void f() {}
^
template-args.cpp:6:5: error: no matching function for call to 'g'
g();
^
template-args.cpp:2:40: note: candidate template ignored: couldn't infer template argument 'N'
template<int N = 1000000 * 10240> void g() {}
^
3 errors generated.
Do you have some other template arguments usage in mind?
https://reviews.llvm.org/D42938
More information about the cfe-commits
mailing list