From owner-freebsd-toolchain@FreeBSD.ORG Thu Nov 3 11:01:52 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id EFA1E106566B; Thu, 3 Nov 2011 11:01:52 +0000 (UTC) Date: Thu, 3 Nov 2011 11:01:52 +0000 From: Alexander Best To: Gerald Pfeifer , Matthias Andree , Warner Losh , Roman Divacky Message-ID: <20111103110152.GA31693@freebsd.org> References: <20111017152548.GA66978@freebsd.org> <4E9CAC1A.5040709@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: freebsd-toolchain@freebsd.org 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: Thu, 03 Nov 2011 11:01:53 -0000 On Mon Oct 17 11, Gerald Pfeifer wrote: > 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. however keeping these checks means that for gcc we can never turn on -Wextra, since it enables these checks. while, running clang they can be turned off via "-Wno-tautological-compare", there's no way of turning them off under gcc, except for removing the -Wextra flag again. cheers. alex > > Gerald