<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Undefined behaviour passing sanitizers and not reproducible in other compilers"
   href="https://bugs.llvm.org/show_bug.cgi?id=52177">52177</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Undefined behaviour passing sanitizers and not reproducible in other compilers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Golovanov12345@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hello. I have the following code: <a href="https://pastebin.com/nxsF75JV">https://pastebin.com/nxsF75JV</a>. 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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>