Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Nov 2011 13:13:04 -0800
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        Alexander Best <arundel@freebsd.org>
Cc:        freebsd-toolchain@freebsd.org, Dimitry Andric <dim@FreeBSD.org>
Subject:   Re: [poc] buildkernel + clang + -Werror
Message-ID:  <C7A0F95A-0F55-47BF-AD60-66DDAEEC3EC7@FreeBSD.org>
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 12: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. ;)

Tautologic checks are good because they may find problems you never =
thought about. The examples pointed out are quite simple and are missing =
the point. You have to thinking about crazy macros.
The only argument against this tautological check that I agree with is =
when the code is explicitly trying to be safe. If the developer checks =
for "i < 0" when indexing an array he/she is trying to guard against =
possible pitfalls in the future when someone suddenly decides to change =
the variable type to become signed. One possible security vulnerability =
was avoided because that developer checked for negative values.
I'm against turning this off by default, but it should not cause an =
error.

Regards,
--
Rui Paulo




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C7A0F95A-0F55-47BF-AD60-66DDAEEC3EC7>