guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Procps in core-updates


From: Andreas Enge
Subject: Re: Procps in core-updates
Date: Mon, 20 Mar 2023 15:54:53 +0100

Hello Michael,

Am Sun, Mar 19, 2023 at 06:36:09PM +0100 schrieb Michael Schierl:
> At the first printf, GCC knows that val still resides in some floating
> point register of your CPU (be it SSE, MMX or x87 registers, depending
> on the processor models your gcc targets).
> Hardware floating point registers on x86 are a mess, and they usually do
> not have the same precision as the IEEE floating point values that are
> stored in variables (e.g. on the stack or heap), but are slightly more
> precise.

this is an interesting guess, and at least gives a hint of why things
happen. I am attaching a simplified C file and the corresponding assembly
output; which I cannot read, but there are differences between the two
invocations of fprintf.

Now to me this still looks like a GCC bug, which is supposed to honour
the IEEE 754 standard for floating point as specified in the C99 standard
(the compiler flag -std=gnu99 was used to compile the file) at least for
"simple" operations. Comparisons should be exact. But I found this:
   https://gcc.gnu.org/wiki/FloatingPointMath
"Note on x86 and m68080 floating-point math
For legacy x86 processors without SSE2 support, and for m68080 processors,
GCC is only able to fully comply with IEEE 754 semantics for the IEEE
double extended (long double) type." So this appears to be a bug with a
"wontfix" tag...

And as indicated there, the compiler option -ffloat-store makes the problem
go away!

The weirdest thing is that actually the value is the integer 123. So it
should be stored in any kind of register exactly.

Thanks for making me learn something new!

Actually I also found an upstream patch:
   https://gitlab.com/procps-ng/procps/-/issues/271
which I will apply now.

Andreas

Attachment: test_strtod_nol.c
Description: Text document

Attachment: test_strtod_nol.o
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]