RFR: 8324833: Signed integer overflows in ABS [v3]

Andrew Haley aph at openjdk.org
Tue Feb 6 09:09:55 UTC 2024


On Mon, 5 Feb 2024 20:37:48 GMT, Dean Long <dlong at openjdk.org> wrote:

> The undefined behavior I was talking about is what abs(INT_MIN) returns on two's complement

I don't believe ABS is undefined if we go from signed to unsigned, via uabs, and back to signed. The conversion from signed->unsigned is well defined, as is the negation of the unsigned value, and the conversion from unsigned back to signed is at worst implementation defined. ABS is undefined when there is an arithmetic overflow, and in this case there is none.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17617#issuecomment-1929070367


More information about the graal-dev mailing list