-std and -pedantic interact.
Let's fix that...
Post by Ben Bacarisse
The compiler can accept several base standards, such as 'c90' or
'c++98', and GNU dialects of those standards, such as 'gnu90' or
'gnu++98'. When a base standard is specified, the compiler accepts
all programs following that standard plus those using GNU extensions
that do not contradict it. For example, -std=c90 turns off certain
features of GCC that are incompatible with ISO C90, such as the asm
and typeof keywords, but not other GNU extensions that do not have a
expression. On the other hand, when a GNU dialect of a standard is
specified, all features supported by the compiler are enabled, even
when those features change the meaning of the base standard. As a
result, some strict-conforming programs may be rejected. The
particular standard is used by -Wpedantic to identify which features
are GNU extensions given that version of the standard. For example
-std=gnu90 -Wpedantic warns about C++ style '//' comments, while
-std=gnu99 -Wpedantic does not.
Issue all the warnings demanded by strict ISO C and ISO C++; reject
all programs that use forbidden extensions, and some other programs
that do not follow ISO C and ISO C++. For ISO C, follows the version
of the ISO C standard specified by any -std option used.
Valid ISO C and ISO C++ programs should compile properly with or
without this option (though a rare few require -ansi or a -std option
specifying the required version of ISO C). However, without this
option, certain GNU extensions and traditional C and C++ features are
supported as well. With this option, they are rejected.
-Wpedantic does not cause warning messages for use of the alternate
keywords whose names begin and end with '__'. Pedantic warnings are
also disabled in the expression that follows __extension__. However,
only system header files should use these escape routes; application
programs should avoid them. See Alternate Keywords.
Some users try to use -Wpedantic to check programs for strict ISO C
it finds some non-ISO practices, but not all—only those for which ISO
C requires a diagnostic, and some others for which diagnostics have
A feature to report any failure to conform to ISO C might be useful
in some instances, but would require considerable additional work and
would be quite different from -Wpedantic. We don't have plans to
support such a feature in the near future.
Where the standard specified with -std represents a GNU extended
dialect of C, such as 'gnu90' or 'gnu99', there is a corresponding
base standard, the version of ISO C on which the GNU extended dialect
is based. Warnings from -Wpedantic are given where they are required
by the base standard. (It does not make sense for such warnings to be
given only for features not in the specified GNU C dialect, since by
definition the GNU dialects of C include all features the compiler
supports with the given option, and there would be nothing to warn
Give an error whenever the base standard (see -Wpedantic) requires a
diagnostic, in some cases where there is undefined behavior at
compile-time and in some other cases that do not prevent compilation
of programs that are valid according to the standard. This is not
equivalent to -Werror=pedantic, since there are errors enabled by
this option and not enabled by the latter and vice versa.