From owner-freebsd-questions@FreeBSD.ORG Tue Jun 10 16:39:06 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF1C837B401 for ; Tue, 10 Jun 2003 16:39:06 -0700 (PDT) Received: from smtp0.adl1.internode.on.net (smtp0.adl1.internode.on.net [203.16.214.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20E7843FCB for ; Tue, 10 Jun 2003 16:39:05 -0700 (PDT) (envelope-from malcolm.kay@internode.on.net) Received: from beta.home (ppp2159.sa.padsl.internode.on.net [150.101.28.110]) h5ANd1CT036423; Wed, 11 Jun 2003 09:09:01 +0930 (CST) Content-Type: text/plain; charset="iso-8859-1" From: Malcolm Kay Organization: At home To: Sean Chittenden Date: Wed, 11 Jun 2003 09:09:00 +0930 User-Agent: KMail/1.4.3 References: <20030609230324.GL65470@perrin.int.nxad.com> <200306101928.30765.malcolm.kay@internode.on.net> <20030610200041.GR65470@perrin.int.nxad.com> In-Reply-To: <20030610200041.GR65470@perrin.int.nxad.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200306110909.00568.malcolm.kay@internode.on.net> cc: questions@freebsd.org Subject: Re: gcc me harder: -Wconversion bug? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jun 2003 23:39:07 -0000 On Wed, 11 Jun 2003 05:30, Sean Chittenden wrote: > > > > It seems to me that this is doing exactly what is claimed for > > > > -Wconversion. To quote from the gcc man page: > > > > -Wconversion > > > > Warn if a prototype causes a type conversion that > > > > is different from what would happen to the same ar- > > > > gument in the absence of a prototype. ... > > > > > > > > Now in the absence of a prototype for f() the argument true would= be > > > > promoted from char/bool to int before being passed to the > > > > function. With the prototype in scope it is not promoted. Differe= nt > > > > argument widths so warning delivered. > > > > > > % cpp test.c > > > # 1 "test7.c" > > > # 1 "" > > > # 1 "" > > > # 1 "test7.c" > > > # 1 "test7.h" 1 > > > # 13 "test7.h" > > > void f(char b); > > > # 2 "test7.c" 2 > > > > > > int > > > main(int argc, char *argv[]) { > > > f((((char)1))); > > > > > > return(0); > > > } > > > > > > void > > > f(char b) { > > > } > > > > > > Am I missing something that says that there isn't the prototype of > > > the same width? Last time I checked my vision, f(char b) was the > > > same as f(char b)... :-/ or am I missing something? I believe > > > that gcc's promoting the char to an int or to some other non-1 > > > byte width data type... but I'm not seeing how, where, or why. > > > -sc > > > > According to the man page we are comaring what does happen with the > > prototype in scope with what would have happened if the prototype > > was not there. > > > > You are aware theat the rules of C require that in the absence of a > > prototype actual integer calling arguments of less width than int > > (usually char and short) must be promoted to int before the call? > > Wow, that's a really worthless warning. I had to re-read it in the AM > to fully appreciate its non-usefulness for properly written software. > Thanks... when reading the error message and skimming the man page, I > thought it was promoting width of the argument to 4 bytes, not that > "in the event that the prototype isn't here, things will get hard to > debug." Thank you, for your incite. -sc Gcc has many warning options and quite a few would be classified as not applicable for general use (but might be useful to someone carrying on a=20 particular investigation). This particular one is not, to my knowledge, included in any of the catchalls such as -Wall or -W. Malcolm