https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470
--- Comment #27 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> --- (In reply to Vincent Lefèvre from comment #26) > But if I understand Piotr Engelking's point, UINT_MAX + 1 + s is not in the > range 0..SHRT_MAX mentioned above, thus cannot be equal to u % 100. Said > otherwise, the promotion has no visible effect here (if s is negative, then > the comparison will be false, as if promotion did not occur), so that there > is no need to warn. Fair enough. But how can the compiler be certain that the developer realized u and u % 100 is unsigned? Maybe when (s)he wrote the code the expectation was for the RHS to be within [-99..99]. > That said, this is very specific code, and it might not be worth to handle > it. And IMHO, this is more than what this PR is about. I tend to agree. It's a slightly different problem and IMHO not a 100% obvious false positive. I believe this PR should be about dropping the warning where signed -> unsigned promotion or implicit conversion cannot change the value because the value range of the signed variable is limited to values >= 0.