Determine GCC -Wall flags enabled
Projects using GCC, G++, and Gfortran compilers often set the -Wall
option as default.
The intent of -Wall
is to enable a common subset of warnings that are generally useful for catching potential issues in your code.
However, new warnings may be
buggy
to the point of breaking builds on valid code, or cause false warnings.
It may be beneficial to not enable -Wall
by default for end-user builds, but only for development builds.
GCC does not appear to have a way to tell what warnings are enabled by -Wall
programmatically.
Instead, one must refer to the GCC
documentation
or even the GCC source code to see which warning flags are included in -Wall
.
For example, in Gfortran 15.1, the -Wall
option includes the -Wexternal-argument-mismatch
warning, which was broke builds on valid code, and was fixed in Gfortran 15.2.