Patch for incorrect execute/divconst-2.c

Jeffrey A Law law@cygnus.com
Tue Mar 14 10:11:00 GMT 2000


  In message < Pine.BSF.4.10.10003110755460.17527-100000@dair.pair.com >you write
:

  > I rewrote the test to check for standards-compliant results like
  > arith-rand.c, but kept what seemed the "point" of the test, the
  > divide-by-(-2147483648) constant stuff.
Thanks.

  > 
  > Unfortunately this uncovers other GCC problems: the "quot * -2147483648"
  > gets optimized into "quot << 31" on a host with 32-bit HOST_WIDE_INTs,
  > regardless of sizeof long on the actual target,
When precisely is that not a safe thing to do?


  > and abs(-2147483648)
  > yields itself, which compares as negative on the i386.
abs returns an int, which is probably the real bug (IMHO).  If integers are
32bits, then there's no way to represent abs (-2147483648).  According 
to the abs man page:

       Trying to take the absolute value  of  the  most  negative
       integer is not defined.



  > Should I commit this, or break some more stuff? :-)
  > Perhaps I should remove the ABS check, so it doesn't break on ix86-* self?
Given that abs (-MAXINT) is undefined, that check should probably be removed.

The rest of the changes seem quite reasonable.

jeff




More information about the Gcc-patches mailing list