Simon Josefsson wrote: > I guess the effort is to document for each warning variable > the code snippet that triggers it, and discuss whether it is a common > warning and how useful it is. > > > The reasonable set that I recommend is "-Wall". > > I'd like to be able to add more to that list, to help catch build > failures on other systems.
Yes, this is a bit of an effort. Just went through the process with gettext. The list of warnings that I would disable unconditionally would be: nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings nw="$nw -Wtraditional" # All compilers nowadays support ANSI C nw="$nw -Waggregate-return" # All compilers nowadays support ANSI C nw="$nw -Wundef" # All compiler preprocessors support #if UNDEF nw="$nw -Wconversion" # These warnings usually don't point to mistakes. nw="$nw -Wsign-conversion" # Likewise. nw="$nw -Wtraditional-conversion" # Likewise. nw="$nw -Wpadded" # We don't want to reorder structs for minimum size nw="$nw -Wvla" # We use variable length arrays only when the compiler supports them nw="$nw -Wunreachable-code" # Complains about many uses of strcmp, due to glibc headers. nw="$nw -Wlogical-op" # Complains about many uses of strchr, due to glibc headers. nw="$nw -Wcast-qual" # Removing 'const' is one of the purposes of casting pointers. nw="$nw -Wstrict-prototypes" # Complains about definitions of functions with empty argument list nw="$nw -Wold-style-definition" # Likewise. nw="$nw -Winline" # If the compiler does not want to inline some functions, so be it. nw="$nw -Wredundant-decls" # Produces warnings for bison generated code. nw="$nw -Wswitch-enum" # Warns even if there is a 'default:' clause in the switch. nw="$nw -Wunsafe-loop-optimizations" # If the compiler cannot optimize a loop, so be it. nw="$nw -Wbad-function-cast" # Warns even about casts from double to int nw="$nw -Wwrite-strings" # It is sometimes useful to use string literals in place of 'char *', without needing to cast. nw="$nw -Wstrict-overflow" # Yes our code does not rely on signed integer overflow behaviour. nw="$nw -Wpacked" # When we ask for packed structures, we accept misalignment. nw="$nw -Wfloat-equal" # == of floats should be avoided in numerical algorithms, but is needed in testsuites. nw="$nw -Wswitch-default" # Enforces a coding style different from ours. # Disable pointless, undesired parts of -W. warnings="$warnings -Wno-unused-parameter" # Ignored parameters are frequent when a function implements a given function type. warnings="$warnings -Wno-empty-body" # Enforces a coding style different from ours. warnings="$warnings -Wno-sign-compare" # These warnings usually don't point to mistakes. warnings="$warnings -Wno-type-limits" # Type limits are system dependent; we prefer if over #if The list of warnings that I would disable normally but use occasionally would be: nw="$nw -Wc++-compat" # Not all our source files are meant to be compilable in C++ mode. nw="$nw -Wshadow" # Enforces a coding style different from ours. But it can be useful to enable it occasionally. nw="$nw -Wmissing-noreturn" # Only useful when searching for optimizations. But it can be useful to enable it occasionally. nw="$nw -Wformat-nonliteral" # gnulib uses some computed format strings (in argmatch, vasnprintf) warnings="$warnings -Wno-uninitialized" # False positives, due to incomplete data flow analysis done by gcc. Bruno