Re: Keep compiler silence (clang 10, implicit conversion from 'long' to 'double' )
Yuya Watari <watari.yuya@gmail.com>
From: Yuya Watari <watari.yuya@gmail.com>
To: tgl@sss.pgh.pa.us, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, pgsql-hackers@postgresql.org
Date: 2019-11-05T11:43:38Z
Lists: pgsql-hackers
Attachments
- v4-keep-compiler-silence.patch (application/octet-stream) patch v4
Hello Tom and Horiguchi-san, On Tue, Nov 5, 2019 at 1:59 PM Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote: > At Mon, 04 Nov 2019 12:53:48 -0500, Tom Lane <tgl@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.yuya@gmail.com
Commits
-
Fix integer-overflow edge case detection in interval_mul and pgbench.
- 8d380864a523 9.4.25 landed
- 84780d468023 9.5.20 landed
- 15783d057543 9.6.16 landed
- 5f794f7572e1 10.11 landed
- b49b7f94489a 11.6 landed
- f6e72dc9cc8b 12.1 landed
- a7145f6bc8b7 13.0 landed
-
Change floating-point output format for improved performance.
- 02ddd499322a 12.0 cited