[Bug c++/69864] Narrowing conversion warning instead of an error
mgsergio at yandex dot ru
gcc-bugzilla@gcc.gnu.org
Fri Feb 19 08:01:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69864
--- Comment #5 from mgsergio <mgsergio at yandex dot ru> ---
And what about the inconsistency with compilation error on
int main() {
int b{2.3};
}
In that case an error is generated.
And if I use
template <typename T, typename U>
inline T narrowing_check(U const u)
{
return {u};
}
I get a warning.
#include <iostream>
using namespace std;
int main() {
int b{2.3};
(void)b;
return 0;
}
g++-5 -std=c++11 1.cc
1.cc: In function 'int main()':
1.cc:5:12: error: narrowing conversion of '2.2999999999999998e+0' from 'double'
to 'int' inside { } [-Wnarrowing]
int b{2.3};
^
More information about the Gcc-bugs
mailing list