[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [Bug 1821444] Re: qemu-ppc (user) incorrectly translates fl
From: |
Sergei Trofimovich |
Subject: |
[Qemu-devel] [Bug 1821444] Re: qemu-ppc (user) incorrectly translates float32 arithmetics |
Date: |
Sat, 23 Mar 2019 11:13:14 -0000 |
Shorter example without relying on printf() implementation. Looks like
uint32_t<->float<->double transitions are enough.
$ cat a.c
#include <stdio.h>
#include <stdint.h>
int main() {
volatile uint32_t i = 1;
volatile float f;
volatile double d;
*(volatile uint32_t*)&f = i;
d = f; f = d; // double conversion
i = *(volatile uint32_t*)&f;
printf("0x1 = %x\n", i);
}
$ powerpc-unknown-linux-gnu-gcc -O2 a.c -Wall -o a -fno-strict-aliasing
-fno-stack-protector -static && qemu-ppc ./a
0x1 = 2
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1821444
Title:
qemu-ppc (user) incorrectly translates float32 arithmetics
Status in QEMU:
New
Bug description:
I'm using qemu-3.1.0 (Gentoo).
When I was running regression test suite via qemu-ppc for GHC I
noticed a few uint32_t<->float32 failures I did not expect to
encounter.
Here is an example
$ cat a.c
#include <stdio.h>
#include <stdint.h>
int main() {
volatile uint32_t i = 1;
printf("0x1 = %e\n", *(volatile float*)&i);
}
$ powerpc-unknown-linux-gnu-gcc -O2 a.c -Wall -o a -fno-strict-aliasing
-fno-stack-protector -static && ./a
0x1 = 2.802597e-45
$ scp a timberdoodle.ppc64.dev.gentoo.org:~/
a
100% 826KB 102.0KB/s 00:08
$ ssh timberdoodle.ppc64.dev.gentoo.org ./a
0x1 = 1.401298e-45
$ qemu-ppc ./a
0x1 = 2.802597e-45
Looks like off-by-one bit somewhere. I'm not sure if it's FPU
instruction or some internals of printf() that are emulated
incorrectly.
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1821444/+subscriptions