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

From: Yuya Watari <watari(dot)yuya(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 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-06 02:32:38
Message-ID: CAJ2pMkYNr7GikazuN0yKjGsa=OFbA9RrTU0_fm8w_Onns1ZV6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Tom,

Thank you for replying.

On Wed, Nov 6, 2019 at 12:04 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Yuya Watari <watari(dot)yuya(at)gmail(dot)com> writes:
> > The added macro FLOAT8_FITS_IN_INT32() does not check NaN explicitly,
> > but it sufficiently handles the case.
>
> Really? I don't think anything is guaranteed about how a NaN will
> compare when using C's non-NaN-aware comparison operators.
>
> My thought about this was to annotate the macros with a reminder
> to also check for NaN if there's any possibility that the value
> is NaN.

I agree with your opinion. Thank you for pointing it out.

If the platform satisfies IEEE-754 standard, all comparisons (except
for "not equals") between NaN and other floating values are "false".
[1] In this case, the proposed FLOAT8_FITS_IN_INT32() macro handles
NaN.

[1] https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN

However, this behavior depends on the platform architecture. As you
have said, C language does not always follow IEEE-754. I think adding
explicit checking of NaN is necessary.

I modified the patch and attached it.

Best regards,
Yuya Watari
NTT Software Innovation Center
watari(dot)yuya(at)gmail(dot)com

Attachment Content-Type Size
v5-keep-compiler-silence.patch application/octet-stream 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-11-06 02:37:36 Re: pgbench - refactor init functions with buffers
Previous Message Fujii Masao 2019-11-06 02:31:03 Re: pgbench - extend initialization phase control