This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C: Add new warning -Wunprototyped-calls

On Sat, Apr 6, 2013 at 11:50 PM, Andreas Schwab <> wrote:
> Tobias Burnus <> 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
legalise ...

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 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.
> --
> Andreas Schwab,
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]