[Bug middle-end/42615] Even with -fwrapv, (3*x%3) is assumed to always be equal to 0
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Jan 16 13:34:00 GMT 2010
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-01-16 13:34 -------
Actually it doesn't optimize 3*x%3 as if it were 0 but simply uses signed
arithmetic for the modulo operation resulting in a -2 modulus.
Using ((unsigned)(3 * x)) % 3 will get what you expect.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42615
More information about the Gcc-bugs
mailing list