valgrind causes miscalculation on the following program:
----------------------------------------
#include <stdio.h>
int main (void)
{
volatile union {
long double d;
unsigned long i[2];
} u;
u.i[0] = 1;
u.i[1] = 0;
printf ("%La\n", u.d);
return 0;
}
----------------------------------------
zira:~> gcc tst.c -o tst
zira:~> ./tst
0x0.000000000000001p-16385
zira:~> valgrind ./tst
==3567== Memcheck, a memory error detector
==3567== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3567== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==3567== Command: ./tst
==3567==
0x0p+0
==3567==
==3567== HEAP SUMMARY:
==3567== in use at exit: 0 bytes in 0 blocks
==3567== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==3567==
==3567== All heap blocks were freed -- no leaks are possible
==3567==
==3567== For counts of detected and suppressed errors, rerun with: -v
==3567== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Instead of 0x0.000000000000001p-16385, one gets 0.
Bug found with MPFR: the tset_ld test fails with valgrind for this
reason.