From owner-freebsd-questions@FreeBSD.ORG Tue Jun 10 01:55:44 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 C512537B401 for ; Tue, 10 Jun 2003 01:55:44 -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 B0FFC43FAF for ; Tue, 10 Jun 2003 01:55:43 -0700 (PDT) (envelope-from malcolm.kay@internode.on.net) Received: from beta.home (ppp2159.sa.padsl.internode.on.net [150.101.28.110]) h5A8tYCT086880; Tue, 10 Jun 2003 18:25:39 +0930 (CST) Content-Type: text/plain; charset="iso-8859-1" From: Malcolm Kay Organization: At home To: Sean Chittenden , questions@freebsd.org Date: Tue, 10 Jun 2003 18:25:33 +0930 User-Agent: KMail/1.4.3 References: <20030609230324.GL65470@perrin.int.nxad.com> In-Reply-To: <20030609230324.GL65470@perrin.int.nxad.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200306101825.33674.malcolm.kay@internode.on.net> 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 08:55:45 -0000 On Tue, 10 Jun 2003 08:33, Sean Chittenden wrote: > [ Please CC: me on replies, not on questions@ ] > > Is this a GCC bug with the -Wconversion flag or am I doing something > wrong? I know it's just a warning, but it's irritating me more than > that dumb Dan Quayle quote, "if it weren't for that horse, I wouldn't > have spent an extra year in college..." -sc > > % gcc -v > Using built-in specs. > Configured with: FreeBSD/i386 system compiler > Thread model: posix > gcc version 3.2.2 [FreeBSD] 20030205 (release) > % uname -a > FreeBSD hostname.example.com 5.1-CURRENT FreeBSD 5.1-CURRENT #2: Mon Ju= n 9 > 12:23:34 PDT 2003 =20 > sean@hostname.example.com:/usr/src/sys/i386/compile/HOSTNAME i386 > > > % gcc -Wconversion test.c > test.c: In function `main': > test.c:5: warning: passing arg 1 of `f' with different width due to > prototype > > /* Begin test.h */ > #ifndef __TEST_H__ > #define __TEST_H__ > > #ifndef bool > typedef char bool; > #endif > > #ifndef true > #define true ((bool)1) > #endif > > #ifndef false > #define false ((bool)0) > #endif > > void f(bool b); > #endif > /* End test.h */ > > > /* Begin test.c */ > #include "test.h" > > int > main(void) { > f(true); > return(0); > } > > void > f(bool b) { } > /* End test.c */ It seems to me that this is doing exactly what is claimed for -Wconversio= n. 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 prom= oted=20 from char/bool to int before being passed to the function. With the proto= type in scope it is not promoted. Different argument widths so warning deliver= ed. Malcolm