Hello Tom and Horiguchi-san, On Tue, Nov 5, 2019 at 1:59 PM Kyotaro Horiguchi <horikyota....@gmail.com> wrote: > At Mon, 04 Nov 2019 12:53:48 -0500, Tom Lane <t...@sss.pgh.pa.us> wrote in > > I do concur with creating a macro that encapsulates a correct version > > of this test, maybe like > > > > #define DOUBLE_FITS_IN_INT64(num) \ > > ((num) >= (double) PG_INT64_MIN && \ > > (num) < -((double) PG_INT64_MIN))
Thank you for your comments. The proposed macro "DOUBLE_FITS_IN_INT64" is a good and simple way to check the overflow. According to that, I revised the patch, which includes regression tests. In the patch, I additionally modified other occurrences as follows. ========= +#define FLOAT8_FITS_IN_INT32(num) \ + ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN)) ========= - if (unlikely(num < (float8) PG_INT32_MIN || - num >= -((float8) PG_INT32_MIN) || - isnan(num))) + /* Range check */ + if (unlikely(!FLOAT8_FITS_IN_INT32(num))) ========= The added macro FLOAT8_FITS_IN_INT32() does not check NaN explicitly, but it sufficiently handles the case. Best regards, Yuya Watari NTT Software Innovation Center watari.y...@gmail.com
v4-keep-compiler-silence.patch
Description: Binary data