This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: unsigned / double propagation weirdness?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]