From owner-freebsd-hackers Thu Oct 29 05:00:28 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA20567 for freebsd-hackers-outgoing; Thu, 29 Oct 1998 05:00:28 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA20556 for ; Thu, 29 Oct 1998 05:00:24 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.1a/8.9.1) with ESMTP id OAA10731; Thu, 29 Oct 1998 14:00:11 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id OAA11230; Thu, 29 Oct 1998 14:00:10 +0100 (MET) Message-ID: <19981029140009.23485@follo.net> Date: Thu, 29 Oct 1998 14:00:09 +0100 From: Eivind Eklund To: Luigi Rizzo , hackers@FreeBSD.ORG Subject: Re: compiler prototype question... References: <199810290453.FAA07168@labinfo.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1i In-Reply-To: <199810290453.FAA07168@labinfo.iet.unipi.it>; from Luigi Rizzo on Thu, Oct 29, 1998 at 05:53:44AM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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