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

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


On 01/11/2018 12:10 PM, Jakub Jelinek wrote:
> On Thu, Jan 11, 2018 at 11:41:19AM -0700, Martin Sebor wrote:
>> Declaring a function without a prototype has been deprecated
>> for nearly two decades (since C99) and may be removed from
>> the C language in C2X.  To prompt programs to transition to
>> the more modern and safer style, PR 82922 requests to enable
>> Wstrict-prototypes in -Wextra.
>
> Does it really warn for
>
> int
> main ()
> {
> ...
> }
>
> ?  main isn't called from C code, there is no reason why it should
> use prototypes.  In the testsuite we have over 5000 C tests that do
> something like that.

It does.  Maybe most of those tests aren't compiled with -Wall.
But I didn't spend too much time analyzing the tests that failed
due to these warnings.  I just added prototypes to every function
in such tests that was missing it.  Where it looked like it might
compromise the test I pruned the warning.

> Furthermore, this should have been suggested in stage1, not 3 days before
> end of stage3 IMNSHO.

Unfortunately, I didn't get to it sooner.  However, and also
IMNSHO, since the usage has been deprecated since 1999 and
given the risks associated with calling such functions,
the option could and should have been added to -Wextra at least
a decade ago.  So forgive me for being a few weeks late with my
proposal to try rectify that.

Martin



More information about the Gcc-patches mailing list