>> What would be the best way to handle this? We certainly don't need to do >> anything on systems where INT_MAX == -INT_MIN, but a simple compiler >> directive should help to detect that case. >> >> In the event that abs(INT_MIN) > abs(INT_MAX), should we silently >> saturate the result to INT_MAX, or should we error? >> >> I'll be happy to put in a patch for this once I know what the behavior >> should be. >> >> --Andrew Whitworth > > Any ruling on this?
The current implementation is wrong. abs takes and returns an int, but parrot INTVAL is not guaranteed to be int. Even worse, "Trying to take the absolute value of the most negative integer is not defined" (from the linux man page, and the C standard if I remember well). So is not granted that we can take decisions based on the result of abs, must be done before. To obtain a safe implementation, abs must be avoided. -- Salu2