This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/27116] [4.2 Regression] Incorrect integer division (wrong sign).
- From: "guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Apr 2006 05:28:37 -0000
- Subject: [Bug c/27116] [4.2 Regression] Incorrect integer division (wrong sign).
- References: <bug-27116-12512@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from guillaume dot melquiond at ens-lyon dot fr 2006-04-12 05:28 -------
> This is undefined only if b is known to be negative otherwise it is defined.
What is undefined? The value of "b" does not matter here. As soon as "a" is
INT_MAX, the computed value with the optimization will be the exact opposite of
the computed value without the optimization, whatever the sign of "b". So the
result is always wrong.
As far as I understand it, the compiler should be allowed to add a unary minus
only if it can prove (VRP?) that INT_MIN is outside the range of the
expression. However, for compilations with -fno-wrapv, a range excluding
INT_MIN should be added after any unary minus written by the user. As a
consequence of these two points, when nothing is known about "a" and -fno-wrapv
is in effect, the compiler would be allowed to optimize (-a)/(-b) (PR 23669)
but would be forbidden to optimize (-1-a)/(-b).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27116