Date: Thu, 3 Nov 2011 11:01:52 +0000 From: Alexander Best <arundel@freebsd.org> To: Gerald Pfeifer <gerald@pfeifer.com>, Matthias Andree <mandree@FreeBSD.org>, Warner Losh <imp@bsdimp.com>, Roman Divacky <rdivacky@freebsd.org> Cc: freebsd-toolchain@freebsd.org Subject: Re: [toolchain] disable -Wtautological-compare for clang Message-ID: <20111103110152.GA31693@freebsd.org> In-Reply-To: <alpine.LNX.2.00.1110172158390.2807@gerinyyl.fvgr> References: <20111017152548.GA66978@freebsd.org> <4E9CAC1A.5040709@FreeBSD.org> <alpine.LNX.2.00.1110172158390.2807@gerinyyl.fvgr>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111103110152.GA31693>