Re: src/include/utils/float.h comment one link stable - Mailing list pgsql-hackers

From David Rowley
Subject Re: src/include/utils/float.h comment one link stable
Date
Msg-id CAApHDvrC9rtjJxQgnbUcNW0MUsD-=+vBTWSAq3AsNsFnUTGUkw@mail.gmail.com
Whole thread Raw
In response to Re: src/include/utils/float.h comment one link stable  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: src/include/utils/float.h comment one link stable
List pgsql-hackers
On Tue, 7 Oct 2025 at 02:11, Daniel Gustafsson <daniel@yesql.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

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: split func.sgml to separated individual sgml files
Next
From: Tom Lane
Date:
Subject: Re: split func.sgml to separated individual sgml files