Re: src/include/utils/float.h comment one link stable

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: src/include/utils/float.h comment one link stable
Date: 2025-10-06 15:03:46
Message-ID: CAApHDvrC9rtjJxQgnbUcNW0MUsD-=+vBTWSAq3AsNsFnUTGUkw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 7 Oct 2025 at 02:11, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> Judging by the cec8394b5ccd3 this was added for MSVC 2013 support, and commit
> 8fd9bb1d9654c59d bumped the minimum requirement to MSVC 2019, so I wonder if
> this at all relevant anymore?

Looks like these were added in cec8394b5 for VS2013 support.

Going by [1] it's talking about a bug relating to having to use the
pragma outside of the function body to disable warnings >= 4700

The warning that's being disabled is talked about in [2] and relates
to floating point overflow. I do get a warning in VS2022 if I try to
compile the fragment in [2] with the flags mentioned:

>cl /W2 /Od test.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35215 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

test.c
test.c(5): warning C4056: overflow in floating-point constant arithmetic

However, I don't seem to be able to get rid of that warning no matter
where I put the #pragma to try to disable it.

As for float.h, I would have assumed it was the "return (float4)
(HUGE_VAL * HUGE_VAL);" that would cause the warning, but the #pragma
to put the warning back to default is before that line, so I'm not
sure what's going on there.

Going by the draft C11 standard in [3], on page 230 it looks like
INFINITY is always defined now, so maybe we can get rid of the other
code and just always "return (float4) INFINITY;"? I did try that with
VS2022 just to make sure and I don't get a warning.

Given the INFINITE stuff seems standard now, tried the attached patch,
and it compiles for me. The comment about the definitions for isnan
and isinf in src/port seem wrong. I didn't find anything in there, so
removed that part.

Here's what I tried. Compiles without warnings in VS2022.

David

[1] https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/120968
[2] https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4756?view=msvc-170
[3] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf

Attachment Content-Type Size
float_header_cleanup.patch application/octet-stream 2.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-10-06 15:13:24 Re: split func.sgml to separated individual sgml files
Previous Message Bruce Momjian 2025-10-06 14:58:31 Re: split func.sgml to separated individual sgml files