https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83584
--- Comment #16 from Tim Rentsch <txr at alumni dot caltech.edu> ---
(In reply to Andrew Pinski from comment #14)
> -pedantic is not designed to reject all programs that are not strictly
> conforming, but to enable emitting all _required_ diagnostics. I
> don't think a conversion between function and object pointer type
> requires a diagnostic.
A conversion between function and object pointer type does not require a
diagnostic. The point of my comment is that rejecting a program on that
basis is consistent with the Standard. Moreover, it is reasonable for
gcc to reject such a program on that basis, as explained below.
The -pedantic option is not designed to reject all programs that are not
strictly conforming. Indeed it could not do so because detecting exactly
those cases is not computable.
I agree that the -pedantic option is meant to enable emitting all required
diagnostics. But it is not meant to emit _only_ those diagnostics that
the Standard requires. For example, there is this case:
static int foo[]; /* given a size later in the source */
Compiling with -pedantic (note: not -pedantic-errors!) and no other
options gives
error: array size missing in 'foo'
This construct is syntactically valid and has no constraint violations,
yet it is rejected under -pedantic. (Rejecting the program is okay
because the construct itself has undefined behavior, under 6.9.2 p3.)
I believe -pedantic is meant to accept(*) only those programs that are
accepted by other compilers that strictly follow what ISO C requires
(assuming the same type sizes, etc). That is, -pedantic is meant to be
conservative, allowing only those programs that any other conforming
implementation would not reject. Hence it is reasonable for -pedantic to
reject the construct shown above, because some implementations might not
be able to handle it. For the same reasons it is reasonable for -pedantic
to reject programs with a conversion between an object pointer type and a
function pointer type. More strongly, it would be _un_reasonable for such
a program to be allowed under -pedantic-errors, because they very likely
would be rejected by other conforming implementations; allowing such
programs pretty much defeats the purpose of -pedantic.
(*) Here "accept" is meant in the sense of not issuing any diagnostics
for, regardless of whether the diagnostics are warnings or errors.