https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61778
Bug ID: 61778
Summary: inaccurate conversion of floating constants with the
IBM long double format
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent-gcc at vinc17 dot net
On PowerPC, which uses the IBM long double format (double-double arithmetic),
the conversion of floating constants of long double type is inaccurate, as
shown by the following code:
#include <stdio.h>
#define STRINGIFY(S) #S
#define MAKE_STR(S) STRINGIFY(S)
#define CAT1(X) 1 ## X
#define CAT2(X) CAT1(X)
#define LD0 .000000000000000000000000000000000001L
#define LD1 CAT2(LD0)
int main (void)
{
long double x = 1.0L + LD0, y = LD1;
if (x > 1.0L && y == 1.0L)
{
printf ("Bad conversion of " MAKE_STR(LD1) "\n");
printf ("Got 1 instead of about 1 + %La\n", x - 1.0L);
return 1;
}
return 0;
}
On gcc110.fsffrance.org:
$ gcc ldtest.c -o ldtest
$ ./ldtest
Bad conversion of 1.000000000000000000000000000000000001L
Got 1 instead of about 1 + 0x1.54484932d2e72p-120
The compiler on this machine is:
gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)