Reputation: 43662
I have a C++98 project on linux with g++ 4.7.3 and I'm getting lots of warnings about "narrowing conversion is ill-formed in C++11"
How come? I'm not even using C++11
Upvotes: 1
Views: 283
Reputation:
Those warnings are "this is valid now, but won't be valid in the future" warnings. They're specifically designed for code that is valid C++98, that won't cause a compilation error in C++98 mode, but would cause problems if you intend to switch to C++11 in the future. They don't get enabled by default, but do by -Wall
. If you're really sure that that isn't going to happen, you can change -Wall
to -Wall -Wno-c++11-compat
Example code:
unsigned u[] = {-1};
$ g++ -c test.cc -ansi -pedantic $ g++ -c test.cc -ansi -pedantic -Wall test.cc:1:19: warning: narrowing conversion of ‘-1’ from ‘int’ to ‘unsigned int’ inside { } is ill-formed in C++11 [-Wnarrowing] unsigned u[] = {-1}; ^ $ g++ -c test.cc -ansi -pedantic -Wall -Wno-c++11-compat
Upvotes: 1