[PATCH/RFC] enable -Wstrict-prototypes (PR 82922)

Martin Sebor msebor@gmail.com
Thu Jan 11 20:46:00 GMT 2018


On 01/11/2018 01:17 PM, Joseph Myers wrote:
> Code intended to work as both C and C++ may well use () for no arguments.
> Maybe what's enabled by -Wextra should be a subset of the warning that
> allows function definitions with ()?  Especially since if C does remove
> unprototyped functions at some point (and as I recall, people were happy
> with the idea for C11, but no paper was put forward with concrete wording
> changes, so nothing happened), there's the question of what () should then
> mean, and the obvious answer would be that C versions without unprototyped
> functions should define () as meaning the same as (void), like C++.

WG14 hasn't yet discussed which deprecated features will be removed
in C2X and what the deprecation might look like, but the convener
mentioned at the last meeting wanting start going through the list
and making decisions about each.  No proposal to do that for C2X
is necessary.

The change you suggest seems reasonable to me for new code but it
would break legacy code.  I can't speak to how WG14 would respond
to it but to consider it the committee would need a proposal.

We have already discussed some of this on this list in the context
of the -Wcast-function-type warning.  I said I'd put together a paper
on the topic and so it should probably mention your suggestion as
well.  If you have other ideas or if you think collaborating on
a paper would be useful I'd be happy to.

Whatever happens in C2x, I'm confident that GCC will continue to
support the feature for compatibility, and so it wouldn't be
a waste of time to refine the warning and be made more useful.
For instance, complaining about the definition of main() (as
opposed to a forward declaration) does seem overly pedantic and
could be suppressed.  Thinking about the C/C++ intersection and
maybe partitioning the warning into subsets might be worthwhile
too.

Martin



More information about the Gcc-patches mailing list