Date: Sun, 6 Nov 2011 17:34:33 -0700 From: Warner Losh <imp@bsdimp.com> To: Alexander Best <arundel@FreeBSD.org> Cc: freebsd-toolchain@FreeBSD.org, Dimitry Andric <dim@FreeBSD.org> Subject: Re: [poc] buildkernel + clang + -Werror Message-ID: <D6F71344-5C2B-439C-AB0E-7A0F52E0C472@bsdimp.com> In-Reply-To: <20111106205805.GA78142@freebsd.org> References: <20111105102102.GA54596@freebsd.org> <20111106172835.GO2258@hoeg.nl> <20111106203316.GA73216@freebsd.org> <4EB6F38E.2080006@FreeBSD.org> <20111106205805.GA78142@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Nov 6, 2011, at 1:58 PM, Alexander Best wrote: > On Sun Nov 6 11, Dimitry Andric wrote: >> On 2011-11-06 21:33, Alexander Best wrote: >> ...=20 >>> the problem is, something like >>>=20 >>> uint x; >>>=20 >>> if (x < 0) ... >>>=20 >>> clang will warn about this, yet it is 100% valid code so my vote = would be to >>> make such an error into a warning. >>=20 >> Sorry, but checking something unsigned to be smaller than zero is = bogus, >> or at the least superfluous, and it's perfectly sane to warn about = this, >> especially since the compiler is not going to emit code for it at = all. >=20 > there was a discussion with the topic > "disable -Wtautological-compare for clang" on freebsd-toolchain@ and = most of > the devs considered this code *not* to be bogus. ;) The code actually is bogus. It may be masking a real problem, because = often times it is a "sanity check" to make sure that you aren't doing = something naughty, like passing -1 for the length. However, if you then = pass the unsigned through a signed value, it suddenly becomes negative, = and you have a hard to spot bug. IIR the the tread, there weren't too = many people offering an opinion... Warner=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D6F71344-5C2B-439C-AB0E-7A0F52E0C472>