[Bug c/66773] sign-compare warning for == and != are pretty useless

vincent-gcc at vinc17 dot net gcc-bugzilla@gcc.gnu.org
Fri Nov 22 16:02:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66773

--- Comment #17 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Segher Boessenkool from comment #15)
> A much better fix is
> 
> void f1(long s, unsigned long u) { unsigned long su = s; if (su == u) g(); }

But what if s is some arbitrary integer type, e.g. that comes from a library?

Even using uintmax_t may be insufficient. For instance, GCC has __uint128.

> Still much better is to not mixed signedness in types at all.

One does not necessarily have the choice. The signedness of some types is not
specified.


More information about the Gcc-bugs mailing list