This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Why is -Wold-style-definition off by default?
- From: Antons Suspans <antox at ml dot lv>
- To: Martin Sebor <msebor at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 9 Nov 2017 18:56:17 +0200
- Subject: Re: Why is -Wold-style-definition off by default?
- Authentication-results: sourceware.org; auth=none
- Dkim-status: no signature
- Domainkey-status: no signature
- References: <20171030122043.GC21898@ax.s16> <fc723c03-c554-1051-c40a-a30c3b78a677@gmail.com>
On Wed, Nov 01, 2017 at 05:59:54PM -0600, Martin Sebor wrote:
> On 10/30/2017 06:20 AM, Antons Suspans wrote:
> > Why is -Wold-style-definition off by default and not implied by -Wall,
> > -Wextra? The following code might be a marginal example, which is
> > compiled without warning about missing prototype and unchecked args
> > (gcc-5.3.0 -Wall -Wextra ex.c).
>
> I recently wondered the same thing. Functions without a prototype
> have been deprecated since C99. As the C committee is starting to
> work on C2X it will consider removing (a subset of) deprecated features.
> I think it would make sense to include the option in -Wall now, well
> ahead of C2X being finalized (it arguably should been done years ago).
> If you'd like to see such a change I suggest opening a request in Bugzilla.
Thank you for your reply and information!
I was pondering this and, frankly, I am not sure I fully understand
the situation, and how gcc warnings are balanced between the standard,
the existent C code, and good practices (for instance, I'd expect C11
6.7.6.3p3 to be fatal).
I have posted a request to include -Wstrict-prototypes in -Wextra:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82922
The following options (and their antecedents) seemed related:
1. -Wimplicit-function-declaration (-Wimplicit | -Wall | -std=c99 | -std=gnu99 or later)
2. -Wimplicit-int (-Wimplicit | -Wall | -std=c99 | -std=gnu99 or later)
3. -Wmissing-parameter-type (-Wextra)
4. -Wold-style-declaration (-Wextra)
5. -Wold-style-definition
6. -Wstrict-prototypes
7. -Wmissing-declarations
8. -Wmissing-prototypes
#1 and #2 are both imposed since C99, and #3 is taken over by #2 since
C99. #7 and #8 are good for header discipline but don't seem crucial.
My concern was calling unprototyped functions and I think it is
completely covered by #1 + #6 (#5 cases hit #6 too). Perhaps #6 (i.e.
-Wstrict-prototypes) is not deserving a place along #1 in -Wall until
the standard changes accordingly, but maybe it is indeed viable in
-Wextra (#4 is there).
Antons
P.S. Martin, please excuse me for the duplicate message.