Thread overview
[Issue 20759] Invalid printf checks for long double on win64
Apr 22, 2020
kinke
Apr 22, 2020
kinke
Feb 27, 2021
Dennis
Dec 17, 2022
Iain Buclaw
April 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20759

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #1 from kinke <kinke@gmx.net> ---
This is specific to DMD and should be an issue with -m32mscoff too. As you said, the MSVC `long double` type is a (for C++, differently mangled than double) 64-bit double (IIRC, Microsoft outright forbids X87 usage in kernel code), while DMD goes with 80-bit X87 reals for those targets (so printf and scanf etc. from the MS runtime cannot be used without converting to lower precision first). LDC uses 64-bit reals for MSVC targets, so this works.

The deprecation wrt. double is IMO valid, as `%Lg` with a double isn't portable and just happens to work for targets with 64-bit reals, but this deprecation should IMO be host-agnostic, i.e., not suddenly popping up when targeting AArch64 or Posix x86.

--
April 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20759

--- Comment #2 from moonlightsentinel@disroot.org ---
(In reply to kinke from comment #1)
> This is specific to DMD and should be an issue with -m32mscoff too.

-m32mscoff yiels the same deprecation message

> The deprecation wrt. double is IMO valid, as `%Lg` with a double isn't portable and just happens to work for targets with 64-bit reals, but this deprecation should IMO be host-agnostic, i.e., not suddenly popping up when targeting AArch64 or Posix x86.

Sure  but it's still a false positive on certain targets. Also, this snippet would still cause deprecations despite working for 64 and 80 bit reals:

printf("%Lg", cast(c_long_double) value);

Should a user have to replace this with e.g.:

static if (is(c_long_double == double))
    enum fmt = "%g";
else
    enum fmt = "%Lg";

printf(fmt, value);

--
April 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20759

--- Comment #3 from kinke <kinke@gmx.net> ---
(In reply to moonlightsentinel from comment #2)
> Should a user have to replace this with e.g.:

Of course not, that's why LDC diverges. ;) The proper long-term solution is IMO redefining D `real` as corresponding to C `long double`, not the 'largest FP size implemented in hardware'.

--
April 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20759

--- Comment #4 from moonlightsentinel@disroot.org ---
Oky, i misunderstood your first post in that regard.

Seems like a reasonable long term solution but it might be useful to recognize & handle 64 bit reals until then.

--
February 27, 2021
https://issues.dlang.org/show_bug.cgi?id=20759

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl

--- Comment #5 from Dennis <dkorpel@live.nl> ---
*** Issue 21666 has been marked as a duplicate of this issue. ***

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20759

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--