Re: Keep compiler silence (clang 10, implicit conversion from 'long' to 'double' )

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yuya Watari <watari(dot)yuya(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Keep compiler silence (clang 10, implicit conversion from 'long' to 'double' )
Date: 2019-11-07 16:30:30
Message-ID: 11924.1573144230@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yuya Watari <watari(dot)yuya(at)gmail(dot)com> writes:
> On Thu, Nov 7, 2019 at 3:10 PM Kyotaro Horiguchi
> <horikyota(dot)ntt(at)gmail(dot)com> wrote:
>> + if (unlikely(!FLOAT8_FITS_IN_INT32(num)) || isnan(num))
>> If compiler doesn't any fancy, num is fed to an arithmetic before
>> checking if it is NaN. That seems have a chance of exception.

> Thank you for pointing it out. That's my mistake. I fixed it and
> attached the patch.

Actually, that mistake is very old --- the existing functions tested
isnan() last for a long time. I agree that testing isnan() first
is safer, but it seems that the behavior of throwing an exception
for comparisons on NaN is rarer than one might guess from the C spec.

Another issue in the patch as it stands is that the FITS_IN_ macros
require the input to have already been rounded with rint(), else they'll
give the wrong answer for values just a bit smaller than -PG_INTnn_MIN.
The existing uses of the technique did that, and interval_mul already
did too, but I had to adjust pgbench. This is largely a documentation
failure: not only did you fail to add any commentary about the new macros,
but you removed most of the commentary that had been in-line in the
existing usages.

I fixed those things and pushed it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-11-07 16:31:23 Re: Reorderbuffer crash during recovery
Previous Message Dmitry Dolgov 2019-11-07 15:43:58 Re: Index Skip Scan