<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 - UBSan false positive vptr with -O1"
   href="https://bugs.llvm.org/show_bug.cgi?id=51879">51879</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBSan false positive vptr with -O1
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>ubsan
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>maic23@live.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25265" name="attach_25265" title="1.cpp">attachment 25265</a> <a href="attachment.cgi?id=25265&action=edit" title="1.cpp">[details]</a></span>
1.cpp

Steps to reproduce with -O1. (Other optimization levels pass fine.)

$ clang++-13 -std=c++17 -O1 -fsanitize=undefined ./1.cpp  && ./a.out

1.cpp:12:25: runtime error: member call on address 0x000000d50238 which does
not point to an object of type 'A'
0x000000d50238: note: object has invalid vptr
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00
00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 1.cpp:12:25 in 
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==462339==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address
0x000000000000 (pc 0x0000004274e7 bp 0x000000000000 sp 0x7ffecb558b00 T462339)
==462339==The signal is caused by a READ memory access.
==462339==Hint: address points to the zero page.</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>