Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod(). - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod().
Date
Msg-id 26733.1352929598@sss.pgh.pa.us
Whole thread Raw
In response to [PATCH] Fix INT_MIN % -1 overflow in int8mod().  (Xi Wang <xi.wang@gmail.com>)
Responses Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod().  (Xi Wang <xi.wang@gmail.com>)
[PATCH 1/2] Fix INT_MIN % -1 overflow in int8mod().  (Xi Wang <xi.wang@gmail.com>)
[PATCH 2/2] Clean up INT_MIN % -1 overflow in int4mod().  (Xi Wang <xi.wang@gmail.com>)
List pgsql-hackers
Xi Wang <xi.wang@gmail.com> writes:
> Return 0 for INT_MIN % -1 (64-bit) instead of throwing an exception.
> This patch complements commit f9ac414c that fixed int4mod().

Meh.  I didn't care for the explicit dependency on INT_MIN in the
previous patch, and I like introducing INT64_MIN even less.  I think
we should be able to reduce the test to just
if (arg2 == -1)    return 0;

since zero is the correct result for any value of arg1, not only
INT_MIN.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Doc patch making firm recommendation for setting the value of commit_delay
Next
From: Xi Wang
Date:
Subject: Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod().