According to Cesar Strauss on 4/21/2007 5:30 PM: > Hi, > > The eval macro in m4-1.4.9 gives wrong results in signed division: > > $ ./m4 > eval(-100/10) > 429496719 > (expected: -10)
Indeed, this is a regression. Thanks for the report. > This comment near the code seems relevant: > > /* Minimize undefined C behavior on overflow. This code assumes > that the implementation-defined overflow when casting > unsigned to signed is a silent twos-complement > wrap-around. */ > > I don't think any overflow handling is needed here, because the > quotient is always smaller than the dividend, in signed integer > division. No, consider INT_MIN/-1. With 2's complement, it is undefined according to C (there is no way to represent -INT_MIN in an int). It turns out that many 2's complement architectures do wraparound and come up with the answer INT_MIN, while Intel causes SIGFPE. So special handling IS needed, just not what I wrote, nor your reversion. I'll come up with something shortly. -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED]
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Bug-m4 mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-m4
