[llvm-bugs] [Bug 52177] New: Undefined behaviour passing sanitizers and not reproducible in other compilers

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 14 08:41:49 PDT 2021


            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: unassignedclangbugs at nondot.org
          Reporter: Golovanov12345 at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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:

 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211014/8768ea69/attachment.html>

More information about the llvm-bugs mailing list