Re: Keep compiler silence (clang 10, implicit conversion from 'long' to 'double' )
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Yuya Watari <watari.yuya@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
Andrew Gierth <andrew@tao11.riddles.org.uk>,
Thomas Munro <thomas.munro@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-11-07T16:30:30Z
Lists: pgsql-hackers
Yuya Watari <watari.yuya@gmail.com> writes: > On Thu, Nov 7, 2019 at 3:10 PM Kyotaro Horiguchi > <horikyota.ntt@gmail.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
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