From owner-cvs-src@FreeBSD.ORG Tue Jun 29 02:44:50 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C0EAB16A4CE; Tue, 29 Jun 2004 02:44:50 +0000 (GMT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 427D743D53; Tue, 29 Jun 2004 02:44:50 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])i5T2il5v003722; Tue, 29 Jun 2004 12:44:47 +1000 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i5T2iinl016126; Tue, 29 Jun 2004 12:44:45 +1000 Date: Tue, 29 Jun 2004 12:44:44 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Andrew Gallatin In-Reply-To: <16608.36423.596831.48148@grasshopper.cs.duke.edu> Message-ID: <20040629123426.G2908@gamplex.bde.org> References: <200406281915.i5SJFeaV060231@repoman.freebsd.org> <20040628193858.GG5635@green.homeunix.org> <20040628201821.GA23618@green.homeunix.org> <16608.36423.596831.48148@grasshopper.cs.duke.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Brian Fundakowski Feldman cc: src-committers@freebsd.org cc: cvs-all@freebsd.org cc: cvs-src@freebsd.org Subject: Re: cvs commit: src/sys/vm vm_map.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jun 2004 02:44:51 -0000 On Mon, 28 Jun 2004, Andrew Gallatin wrote: > Brian Fundakowski Feldman writes: > > > > GCC not actually type-checking here is certainly a bug from my > > viewpoint and one whose existence makes me more than a little > > worried about further problems with min() and friends (ones that > > I did not introduced ;). Are there any GCC experts that can help > > out, here? > > > > -Wconversion would find this.. > > -Wconversion > Warn if a prototype causes a type conversion that is different > from what would happen to the same argument in the absence of a > prototype. This includes conversions of fixed point to floating > and vice versa, and conversions changing the width or signedness > of a fixed point argument except when the same as the default > promotion. > > However its a little bit too restrictive, as it complains about any ^^^^^^ big :-) > mismatch and the compile doesn't get even one C file done before > erroring out. > > If I add -Wconversion to my cflags, it first trips on sys/bus.h > (harmless passing of "1" to a function taking a long), > and then it pukes all over atomic.h: > > In file included from ../../../sys/systm.h:41, > from ../../../cam/cam.c:35: > machine/atomic.h: In function `atomic_set_acq_8': > machine/atomic.h:308: warning: passing arg 2 of `atomic_set_8' with different width due to prototype > machine/atomic.h: In function `atomic_set_rel_8': > machine/atomic.h:308: warning: passing arg 2 of `atomic_set_8' with different width due to prototype > > Any idea what its problem is? This is a FAQ, but I couldn't find the answer in gcc.info. The problem is that -Wconversion doesn't do what you want. It was intended for discovering portability problems in K&R code and/or old code that doesn't always have prototypes in scope. The default promotions can work, but not if there is a prototype that sometimes forces wider args. I forget if the signedness warning was there originally. Signedness mismatches for parameters are subtler than size mismatches and tend to get "fixed" by 2 bogus conversions canceling each other. Bruce