On 2017/5/15 20:02, Vincent Lefevre wrote:
On 2017-05-14 00:43:52 +0800, Liu Hao wrote:
4) If the `FST` or `FSTP` instruction is used to store an invalid
operand to a memory location, an #IA exception is raised regardless
of size of that location.
Since case 2) and 4) differ, a SNaN and an invalid operand are *not*
indistinguishable.
In C, an assignment with no type conversion corresponds to a "copy" or
equivalently nothing, the unary minus is "negate", and fabs is "abs"
(Annex F of the C standard). If you get an exception, then this is a
compiler bug.
Yeah but `printf()` from glibc doesn't think it is a NaN... From your
point of view, is this a glibc bug?
------------------------------------------------------------------
lh_mouse@lhmouse-dev:~$ cat test.c
#include <stdio.h>
#include <math.h>
int main (void)
{
long double ld = 0;
unsigned char data[10] = {
0x5b, 0x01, 0x04, 0x5e, 0x85, 0x00, 0x00, 0x00, 0xd8, 0x59
};
__builtin_memcpy(&ld, data, 10);
printf ("nan = %d, ld = %Lg\n", isnanl(ld), ld);
return 0;
}
lh_mouse@lhmouse-dev:~$ gcc test.c -O3 -lm -Wall -Wextra -pedantic
lh_mouse@lhmouse-dev:~$ ./a.out
nan = 1, ld = 5.11212e+1984
lh_mouse@lhmouse-dev:~$
------------------------------------------------------------------
--
Best regards,
LH_Mouse