What is the difference between using -pedantic-errors
and -Werror=pedantic
in gcc?
According to the documentation of GCC there is a difference:
-pedantic-errors
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.
What errors are included by -pedantic-errors
, but not by -Werror=pedantic
?
What errors are included by -Werror=pedantic
, but not by -pedantic-errors
?
Any example of both types of errors?
A little insight as to why the two options exist separately in chapter 14 of the gcc documentation:
So it sounds like there's some ISO C rules that are not explicitly marked as invalid C but instead valid-ish C. These are the rules that
-pedantic-errors
makes into errors that-Werror=pedantic
doesn't. You'll have to look at the ISO C standard for more information on that.As far as what errors are turned on/off as documented by GCC, there is but 1 that has
-pedantic-errors
explicitly:Note: however it seems that not all the authors of the manual have the same idea. In section 2 it talks about
-pedantic-errors
as if it WAS the same:So I believe you've discovered an editorial discrepancy.