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

--- Comment #21 from Alejandro Colomar <[email protected]> ---
(In reply to Joseph S. Myers from comment #20)
> I think the changed title describes an INVALID bug: there is no false
> positive, -Wsign-compare is behaving as it's meant to and diagnosing cases
> where the comparison of values of integer type involves an implicit
> conversion from signed to signed that might change an integer value, so it
> doesn't act as a heterogeneous comparison of values as if they were
> infinite-precision integers.
> 
> I don't object to having a more specific -Wno-sign-compare-negative-constant
> or similar that excludes warning for the cases discussed here where a
> particular code idiom intends the implicit conversion to occur (especially
> considering the risks involved in adding a cast if the cast ends up being to
> the wrong type).

Jonathan's suggestion was to treat -1 as a special case, diagnosing all others.
 I think that makes sense, as -1 is a well-known error code, while -2 sounds
like an actual -2, and probably should be diagnosed.

If so, it would have to be -Wno-sign-compare-minus-one (or ...-negative-one).

TBH, I don't mind how we do it, as long as we provide a way to disable the
diagnostic for literal -1 with values of type of rank no less than int. 
Whether it's a new flag, or incorporated in the existing one.

Reply via email to