Stéphane Glondu
2021-12-22 12:50:01 UTC
Hello,
While debugging OCaml 4.13.1's testsuite on m68k, I've noticed that the
following:
-----8<-----
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int i = atoi(argv[1]);
union { double d; int64_t i; } u[2];
u[0].i = 0x7FF0000000000001L;
u[1].d = -u[0].d;
printf("%Lx, %F\n", u[i].i, u[i].d);
}
-----8<-----
when compiled with "gcc -O0" and run with argument "1", returns:
fff0000000000000, -INF
which seems to be incorrect.
For reference, on amd64 (and seemingly on arm64, armhf, i386, ppc64el,
s390x as well), it returns:
fff0000000000001, -NAN
which seems to be the correct behaviour.
Does anybody here have an explanation?
Cheers,
While debugging OCaml 4.13.1's testsuite on m68k, I've noticed that the
following:
-----8<-----
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int i = atoi(argv[1]);
union { double d; int64_t i; } u[2];
u[0].i = 0x7FF0000000000001L;
u[1].d = -u[0].d;
printf("%Lx, %F\n", u[i].i, u[i].d);
}
-----8<-----
when compiled with "gcc -O0" and run with argument "1", returns:
fff0000000000000, -INF
which seems to be incorrect.
For reference, on amd64 (and seemingly on arm64, armhf, i386, ppc64el,
s390x as well), it returns:
fff0000000000001, -NAN
which seems to be the correct behaviour.
Does anybody here have an explanation?
Cheers,
--
Stéphane
Stéphane