I would like to find out which is the most extreme error checking flag combination for g++ (4.7). We are not using the new C++11 specification, since we need to cross compile the code with older compilers, and these older compilers (mostly g++ 4.0) often cause problems which simply are ignored by the g++4.7.
Right now we use the following set of flags:
-Wall -Wcomment -Wformat -Winit-self -ansi -pedantic-errors \
-Wno-long-long -Wmissing-include-dirs -Werror -Wextra
but this combination does not identify issues such as a double being passed in to a function which expects int, or comparison between signed and unsigned int and this causes the old compiler to choke on it.
I have read through the documentation and -Wsign-compare
should be enabled by -Wextra
but in practice seems this is not the case, so I might have missed something...
The -ansi
is alias for the default standard without GNU extensions. I'd suggest instead being explicit using -std=c++98
, but it should be default for g++ -ansi
, so not really different.
But generally I've never seen anything that would be accepted by newer gcc and rejected by older gcc on the grounds of being invalid. I suspect any such problem is a bug in the older compiler or it's standard library. Gcc does not have warnings for things that are correct, but didn't work with older versions of it, so you don't have any other option than to test with the older version.
As for the specific issues you mention:
-Wconversion
should help.-Wno-sign-compare
.The compiler should not print warnings for headers found in directories given with -isystem
instead of -I
, so that should let you silence the warning for Qt headers and keep it enabled for your own code. So you should be able to use -Wconversion
.