[Bug c++/78244] Narrowing conversion is accepted in a function template, but it should be rejected
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 8 08:25:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78244
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-11-08
CC| |marxin at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, all releases are affected. Clang rejects the second test-case:
$ clang++ pr78244.cpp -std=c++11
pr78244.cpp:2:31: error: type 'double' cannot be narrowed to 'int' in
initializer list [-Wc++11-narrowing]
auto f(T) -> decltype(int{0.}, void()) { }
^~
pr78244.cpp:2:31: note: insert an explicit cast to silence this issue
auto f(T) -> decltype(int{0.}, void()) { }
^~
static_cast<int>( )
pr78244.cpp:5:9: error: no matching function for call to 'f'
f(0);
^
pr78244.cpp:2:10: note: candidate template ignored: substitution failure [with
T = int]: type 'double' cannot be narrowed to 'int' in initializer list
auto f(T) -> decltype(int{0.}, void()) { }
^ ~~
2 errors generated.
More information about the Gcc-bugs
mailing list