While any given unsigned value usually cannot be negative, a difference
of two unsigned values can be negative iff the subtrahend (i.e. the
second value) is greater than the minuend. For this reason, it is common
to wrap a difference like this in an abs(3) call. Don't warn on these
cases.
Details
Details
- Reviewers
rtrieu
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Oops, you're right. Now I've added the correct list, but how do I get llvm-commits unsubscribed?
Comment Actions
The difference of two unsigned promoted types is also unsigned, so cannot be negative. Perhaps we should word the warning differently in this case, but a warning does seem justified.