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

--- Comment #10 from Alejandro Colomar <alx at kernel dot org> ---
(In reply to Vincent Lefèvre from comment #9)
> (In reply to Paul Eggert from comment #8)
> > (In reply to Jakub Jelinek from comment #4)
> > > just use ~(time_t)0 or similar.
> > That has a cast, and part of the point of this bug report is to avoid casts
> > which are too powerful in C.
> 
> Yes, and in a more general case, if the type of the variable changes, one
> may forget to update the type of the cast. But instead of the i == -1
> comparison, one could do i + 1 == 0. This should avoid the sign-compare
> warning in this particular case.

But this causes readability issues.  For error-handling, programmers are used
to writing ==-1, and doing +1==0 would be significantly weird.  Given that
comparison ==-1 isn't unsafe in any way (given that the LHS is of rank no less
than int), we should stop warning about it.

Reply via email to