unsigned / double propagation weirdness?

Richard Guenther rguenth@tat.physik.uni-tuebingen.de
Mon Feb 23 18:08:00 GMT 2004


Robert Dewar wrote:
> Giovanni Bajo wrote:
> 
>>> you certainly don't want to regard the use of unary
>>> minus on unsigned as something you warn about.
> 
> 
>> What's the rationale for this? I know that other compilers do 
>> implement this
>> warning and I indeed found it useful in the past.
> 
> 
> To me, unary minus on unsigned is both useful, and has a clear and 
> expected meaning (take the twos complement). I would find it most
> irritating to get warnings on this. If it is really the case that
> many/most C programmers are bamboozled by this standard usage in
> the language, perhaps there is an argument for a warning that can
> be turned on, but I certainly would not want to see this in -Wall.

Well, if it's not in -Wall, nobody will actually use it and it will not 
help finding bugs.  The warning should probably be only, if inside
a mixed signed/unsigned expression (where float counts as signed of 
course).  I.e. for completely unsigned expression we should not warn.

Richard.



More information about the Gcc mailing list