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 _______________________________________________ [email protected] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain To unsubscribe, send any mail to "[email protected]"
