nexttowardl for ppc64el generates wrong results
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
On PPC, the non-IEEE 128-bit long double is represented as a pair of doubles. This means that for 1.L, the next representable value in the direction of 2.L should be 1.L + DBL_EPSILON. The nexttowardl function does not seem to produce such a result.
To reproduce, compile and link the following C program and run the resulting executable. The actual output and the expected output is provided below.
### SOURCE (<stdin>):
long double nexttowardl(long double, long double);
int printf(const char *, ...);
int main(void) {
long double eps = nexttowardl(0.L, 1.L);
long double ans = nexttowardl(1.L, 2.L);
long double ref = 1.L + eps;
typedef unsigned char *ucp;
for (ucp p = (ucp)&ref; p < (ucp)&1[&ref]; ++p) {
printf(
}
printf("\n");
for (ucp p = (ucp)&ans; p < (ucp)&1[&ans]; ++p) {
printf(
}
printf("\n");
}
### COMPILER INVOCATION:
gcc -xc - -lm
### RUN OUTPUT:
000000000000f03
000000000000f03
### EXPECTED OUTPUT:
000000000000f03
000000000000f03
### VERSION INFO:
> lsb_release -rd
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Return: 0x00:0
> apt-cache policy libc6
libc6:
Installed: 2.23-0ubuntu7
Candidate: 2.23-0ubuntu11
Version table:
2.23-0ubuntu11 500
500 http://
2.23-0ubuntu10 500
500 http://
*** 2.23-0ubuntu7 100
100 /var/lib/
2.23-0ubuntu3 500
500 http://
Return: 0x00:0