From: | Yuya Watari <watari(dot)yuya(at)gmail(dot)com> |
---|---|
To: | tgl(at)sss(dot)pgh(dot)pa(dot)us, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Keep compiler silence (clang 10, implicit conversion from 'long' to 'double' ) |
Date: | 2019-11-05 11:43:38 |
Message-ID: | CAJ2pMkZ0HPEskk2UgXe4VVZuG2UpApEywZut8UwUM35O=2=TqQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello Tom and Horiguchi-san,
On Tue, Nov 5, 2019 at 1:59 PM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
> At Mon, 04 Nov 2019 12:53:48 -0500, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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(dot)yuya(at)gmail(dot)com
Attachment | Content-Type | Size |
---|---|---|
v4-keep-compiler-silence.patch | application/octet-stream | 7.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuro Yamada | 2019-11-05 12:07:07 | Re: progress report for ANALYZE |
Previous Message | Gilles Darold | 2019-11-05 11:41:41 | Re: [PATCH][DOC] Fix for PREPARE TRANSACTION doc and postgres_fdw message. |