On 03/27/2014 08:05 AM, Thomas Preud'homme wrote:
>> From: gcc-ow...@gcc.gnu.org [mailto:gcc-ow...@gcc.gnu.org] On Behalf Of
>> Andrew Haley
>>
>> Assigning a negative literal to an unsigned variable is well-defined
>> standard C.  Is it really appropriate to warn for correct code?
> 
> There is lots of cases where gcc warn construct in correct
> code. Think for instance at unused variables. I think this is the
> same kind of situation here: the construct is valid but for many (or
> at least some) users it's not something they are likely to use and
> might indicate an error. I think the rationale provided by Daniel is
> sound.

Really?  I suppose we'll have to agree to differ.

The trouble with warnings like this is that they trigger far too
frequently on good (i.e. correct, reasonable, just as the programmer
intended) code.  They bring warnings into disrepute.  They also cause
people to do extra work just to shut the compiler up, and this often
IME leads to inadvertent code breakage.

I suppose the one good thing about this warning is that it can easily
be shut up by casting the literal to unsigned.

Andrew.

Reply via email to