[llvm-bugs] [Bug 43907] New: Double Signaling NaN converted to float becomes INF

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 5 05:14:26 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=43907

            Bug ID: 43907
           Summary: Double Signaling NaN converted to float becomes INF
           Product: new-bugs
           Version: 9.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: feildel at corona-renderer.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

The following piece of code produce incorrect result with clang (and clang-cl)
on Windows:

```
#include <cmath>
#include <limits>

int main() {
    const double quiet_nan_double = std::numeric_limits<double>::quiet_NaN();
    const float converted_to_float = float(quiet_nan_double);
    const bool isnan = std::isnan(converted_to_float);
    return isnan ? 1 : 0;
}
```

The program should return 1. It does on Linux with majors compilers. On Windows
clang (and clang-cl) returns 0 no matter what compilation flags I tried. Here
are some flags I used: 

clang -O3 -Wall -Wextra -g nan_d2f.cpp
clang -O0 -Wall -Wextra -g nan_d2f.cpp
clang -Wall -Wextra -g nan_d2f.cpp
clang-cl /Ox /W4 /EHsc nan_d2f.cpp
clang-cl /W4 /EHsc nan_d2f.cpp

Here is version reported by `clang -v`:

```
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\scoop\apps\llvm\current\bin
```

It was downloaded from here:
https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe#/dl.7z

Let me know if you need more info or cannot reproduce.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191105/bebc92c8/attachment-0001.html>


More information about the llvm-bugs mailing list