gcc bug (possibly)

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Mar 5 10:56:30 AEST 1989


In article <9201 at orstcs.CS.ORST.EDU> budd at mist.cs.orst.edu (Tim Budd) writes:
>Unless I am seriously mistaken in my understanding of prototypes, our version 
>of gcc produces an error in what I believe is a correct program.  
>extern int foo ( short );
>int foo(x)
>short x;
>{ ; }
>I get a message that the argument doesn't match the prototype.

GCC is correct to complain about this usage.

That's because the parameter (formal argument) doesn't match the
prototype.  By using an old-style function definition, you've
required that `x' be passed as an int, then converted to short
upon entry to the function.  The prototype says that it's passed
as a short in the first place.  Those two functions interfaces
are not in general conformable.



More information about the Comp.lang.c mailing list