[Bug c/38470] value range propagation (VRP) would improve -Wsign-compare

inkerman42 at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 28 13:01:00 GMT 2021


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

Piotr Engelking <inkerman42 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |inkerman42 at gmail dot com

--- Comment #24 from Piotr Engelking <inkerman42 at gmail dot com> ---
Created attachment 51071
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51071&action=edit
not useful -Wsign-compare warning involving % operator

Another case where the feature would be useful:

extern int
f(short s, unsigned int u)
{
    return s == u % 100;
}

It would be nice if the compiler noticed that rhs is always within 0..SHRT_MAX,
so the comparison is not surprisingly affected by integer promotion.


More information about the Gcc-bugs mailing list