From owner-freebsd-toolchain@FreeBSD.ORG Tue Oct 18 05:01:26 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4FC21065670 for ; Tue, 18 Oct 2011 05:01:26 +0000 (UTC) (envelope-from gerald@pfeifer.com) Received: from ainaz.pair.com (ainaz.pair.com [209.68.2.66]) by mx1.freebsd.org (Postfix) with ESMTP id 86AFF8FC14 for ; Tue, 18 Oct 2011 05:01:26 +0000 (UTC) Received: from [10.11.127.239] (unknown [12.228.211.90]) by ainaz.pair.com (Postfix) with ESMTPSA id 3B73D3F40F for ; Tue, 18 Oct 2011 01:01:25 -0400 (EDT) Date: Mon, 17 Oct 2011 22:01:31 -0700 (PDT) From: Gerald Pfeifer To: freebsd-toolchain@freebsd.org In-Reply-To: <4E9CAC1A.5040709@FreeBSD.org> Message-ID: References: <20111017152548.GA66978@freebsd.org> <4E9CAC1A.5040709@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [toolchain] disable -Wtautological-compare for clang X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2011 05:01:26 -0000 On Tue, 18 Oct 2011, Matthias Andree wrote: >> any chance we could disable -Wtautological-compare for clang? i don't >> think comparing an unsigned int against < 0 is worth a warning. >> actually it's always nice to have such a seatbelt, in case somebody >> changes the type to int and forgets to introduce such a check. > If your code must be unclean in such a way that it uses deliberately > dead code "just in case someone breaks the semantics", can you not use > -Wno-tautological-compare in that situation? It's not as straightforward, sadly, which is why I mentioned I am on the fence somehow. if (TYPE_MIN <= var && var <= TYPE_MAX) or if (var < TYPE_MIN || var > TYPE_MAX) are not that uncommon, in well written application, and if TYPE_MIN then evaluates to 0, we'll get a warning. > Unless someone goes to paranoia mode and sprays unneeded checks like you > suggest all over the code like an ugly graffity, all such warnings are > worth investigating. In code I've hand my eyes and/or hands on, the > better part of these warnings were pointing to true bugs. In my experience some were, while others were of the class above. Gerald