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

            Bug ID: 52177
           Summary: Undefined behaviour passing sanitizers and not
                    reproducible in other compilers
           Product: clang
           Version: 12.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Hello. I have the following code: https://pastebin.com/nxsF75JV. Basically it
computes sines and cosines for all multiples of pi/32, most of the time
multiplying the previous complex representation by the same constant, but every
8-th time calling expensive functions cos/sin to avoid precision-related
issues. It is clear that the code should report that the cosine of the
outputted angle is zero both times, which happens in ideone/godbolt/wherever,
except my compiler in termux for Android. I compile using the following line:
`g++ -std=c++17 qwe.cpp -o qwe`. When I add `-O0`, everything works properly.
When I add `-O2`, I receive the following output:

```
1
 angles: 1.57080 1.57080
cosines: -0.70711 0.00000
```

When I also pass `-fsanitize=undefined` or `-fsanitize=address`, nothing
changes. My g++ version is clang 12.0.1, but a friend of mine confirmed the
same effect on his clang 11.1.0, also in termux. Please investigate or tell me
that I am wrong.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to