Date: Mon, 17 Oct 2011 22:01:31 -0700 (PDT) From: Gerald Pfeifer <gerald@pfeifer.com> To: freebsd-toolchain@freebsd.org Subject: Re: [toolchain] disable -Wtautological-compare for clang Message-ID: <alpine.LNX.2.00.1110172158390.2807@gerinyyl.fvgr> In-Reply-To: <4E9CAC1A.5040709@FreeBSD.org> References: <20111017152548.GA66978@freebsd.org> <4E9CAC1A.5040709@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.LNX.2.00.1110172158390.2807>