qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [Bug 1821515] [NEW] qemu-ppc (user) incorrectly converts fl


From: Sergei Trofimovich
Subject: [Qemu-devel] [Bug 1821515] [NEW] qemu-ppc (user) incorrectly converts float(nan)->double(non-nan)
Date: Sun, 24 Mar 2019 12:10:28 -0000

Public bug reported:

Noticed on qemu-3.1.0 on GHC test suite where float32 comparisons didn't work 
on NaNs.
Here is the minimal reproducer:

```c
// cat a.c
#include <stdio.h>
#include <math.h>
#include <stdint.h>

int main() {
    volatile float f1 = NAN;
    volatile float f2 = NAN;
    printf ("f1 (%e, %#x) >= f2 (%e, %#x): %s\n",
        f1, *(volatile uint32_t*)&f1,
        f2, *(volatile uint32_t*)&f2,
        (f1 >= f2) ? "True"
                   : "False");
    volatile double d = f1;
    printf ("d (%e, %#llx)\n",
        d, *(volatile uint64_t*)&d);
}
```

```
# incorrect execution:
$ powerpc-unknown-linux-gnu-gcc -O2 a.c -o a -static && qemu-ppc ./a 
f1 (5.104236e+38, 0x7fc00000) >= f2 (5.104236e+38, 0x7fc00000): True
d (5.104236e+38, 0x47f8000000000000)

# correct execution
$ scp a timberdoodle.ppc64.dev.gentoo.org:~/;  ssh 
timberdoodle.ppc64.dev.gentoo.org ./a
f1 (nan, 0x7fc00000) >= f2 (nan, 0x7fc00000): False
d (nan, 0x7ff8000000000000)
```

Note: qemu-ppc handled float32 extension as it was not a NaN
(exp=111..1111) but a normalized number.

** Affects: qemu
     Importance: Undecided
         Status: New

** Attachment added: "statically linked binary"
   https://bugs.launchpad.net/bugs/1821515/+attachment/5249031/+files/ppc-bug

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1821515

Title:
  qemu-ppc (user) incorrectly converts float(nan)->double(non-nan)

Status in QEMU:
  New

Bug description:
  Noticed on qemu-3.1.0 on GHC test suite where float32 comparisons didn't work 
on NaNs.
  Here is the minimal reproducer:

  ```c
  // cat a.c
  #include <stdio.h>
  #include <math.h>
  #include <stdint.h>

  int main() {
      volatile float f1 = NAN;
      volatile float f2 = NAN;
      printf ("f1 (%e, %#x) >= f2 (%e, %#x): %s\n",
          f1, *(volatile uint32_t*)&f1,
          f2, *(volatile uint32_t*)&f2,
          (f1 >= f2) ? "True"
                     : "False");
      volatile double d = f1;
      printf ("d (%e, %#llx)\n",
          d, *(volatile uint64_t*)&d);
  }
  ```

  ```
  # incorrect execution:
  $ powerpc-unknown-linux-gnu-gcc -O2 a.c -o a -static && qemu-ppc ./a 
  f1 (5.104236e+38, 0x7fc00000) >= f2 (5.104236e+38, 0x7fc00000): True
  d (5.104236e+38, 0x47f8000000000000)

  # correct execution
  $ scp a timberdoodle.ppc64.dev.gentoo.org:~/;  ssh 
timberdoodle.ppc64.dev.gentoo.org ./a
  f1 (nan, 0x7fc00000) >= f2 (nan, 0x7fc00000): False
  d (nan, 0x7ff8000000000000)
  ```

  Note: qemu-ppc handled float32 extension as it was not a NaN
  (exp=111..1111) but a normalized number.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1821515/+subscriptions



reply via email to

[Prev in Thread] Current Thread [Next in Thread]