This is the mail archive of the
mailing list for the GCC project.
Re: C: Add new warning -Wunprototyped-calls
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Tobias Burnus <burnus at net-b dot de>, gcc patches <gcc-patches at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Mon, 8 Apr 2013 11:24:36 +0200
- Subject: Re: C: Add new warning -Wunprototyped-calls
- References: <5160963D dot 6090308 at net-b dot de> <m2zjxbib1w dot fsf at igel dot home>
On Sat, Apr 6, 2013 at 11:50 PM, Andreas Schwab <firstname.lastname@example.org> wrote:
> Tobias Burnus <email@example.com> writes:
>> gcc.dg/Wunprototyped-calls.c:13:3: warning: call to function ‘g’ without a
>> real prototype [-Wunprototyped-calls]
> What is a real prototype?
One reason I didn't bother to upstream that patch is language lawyer
We want to catch
int foo ();
int bar (T x)
return foo (x);
int foo (U)
that is, calling foo () from a context where the definition or declaration with
argument specification is not visible. This causes the C frontend to apply
var-args promotion rules to all arguments which may differ from promotion
rules that would be applied when a "real prototype" was visible at the point
of the function call.
I'd just say "without a prototype". int foo(); or just foo(); is specified as
part of 220.127.116.11/14 as "The empty list in a function declarator that is not
part of a definition of that function specifies that no information about the
number or types of the parameters is supplied." (this appears mostly
in K&R style programs where the T D ( identifier-list(opt) ) form is valid).
I am not sure that GCC doing varargs style promotions to calls with
only this kind of declarator is valid or if the program would be rejected
by K&R (and only the GCC extension of varargs functions without
a first named arguments makes us do what we do ...).
The patch was implemented while hunting down "miscompiles" in
either X or ghostscript (I don't remember...).
> Andreas Schwab, firstname.lastname@example.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."