Date: Thu, 29 Oct 1998 14:00:09 +0100 From: Eivind Eklund <eivind@yes.no> To: Luigi Rizzo <luigi@labinfo.iet.unipi.it>, hackers@FreeBSD.ORG Subject: Re: compiler prototype question... Message-ID: <19981029140009.23485@follo.net> In-Reply-To: <199810290453.FAA07168@labinfo.iet.unipi.it>; from Luigi Rizzo on Thu, Oct 29, 1998 at 05:53:44AM %2B0100 References: <199810290453.FAA07168@labinfo.iet.unipi.it>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Oct 29, 1998 at 05:53:44AM +0100, Luigi Rizzo wrote:
> Hi,
>
> can someone tell me why in the following C program:
>
> int c1 (int c);
> int c1 (char c) { return 1 ; }
>
> int c2 (int c);
> int c2 (c) char c; { return 1 ; }
[...]
> To me, c2() seems as bad as the others, and i don't understand why
> the compiler does not complain. It seems that when the prototype
> declares an "int" argument, then any signed/unsigned type is accepted
> for that argument in the non-ansi function body. As you can imagine
> this defeats the usefulness of prototypes and obfuscates code.
> Furthermore, with multiple arguments, i could even be suspicious of
> how the compiler behaves (e.g. does it push a wordsize argument
> and then tries to read it as multiple 1 or 2 byte items ?).
That char is promoted to an int when the call is made, unless a
prototype saying otherwise is in scope.
> and the reason i am asking on hackers...
> there is such code in the kernel, e.g. sys/i386/isa/if_ed.c
> function ed_get_packet() has this problem and i don't know if it
> a bug or what.
I think it should be changed, but it isn't a bug per se.
Eivind.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981029140009.23485>
