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

--- Comment #19 from Daniel Marjamäki <daniel.marjamaki at gmail dot com> ---
(In reply to Segher Boessenkool from comment #15)
> (In reply to Daniel Marjamäki from comment #12)
> > So, how would you fix the warning for `f`? Many programmers would "fix" it
> > with a cast.
> > 
> > Assuming that `s` and `u` can have arbitrary values, here is the proper 
> > code:
> > 
> > void f(long s, unsigned long u) { if (s >= 0 && s == u) g(); }
> > 
> > For this correct code, gcc warns.
> 
> A much better fix is
> 
> void f1(long s, unsigned long u) { unsigned long su = s; if (su == u) g(); }
> 
> which makes it rather explicit what is going on.
> 
> Still much better is to not mixed signedness in types at all.

That does not work.

Imagine that you call f1 like so : `f1(-1L, ~0UL)`. If you don't want that g()
is called when the argument values are mathematically different.. like here..
how do you do?

Reply via email to