This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/42615] Even with -fwrapv, (3*x%3) is assumed to always be equal to 0
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jan 2010 13:34:41 -0000
- Subject: [Bug middle-end/42615] Even with -fwrapv, (3*x%3) is assumed to always be equal to 0
- References: <bug-42615-17390@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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