This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/27116] [4.2 Regression] Incorrect integer division (wrong sign).



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]