<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 - Unaligned movaps in virtual base constructor"
   href="https://bugs.llvm.org/show_bug.cgi?id=35901">35901</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unaligned movaps in virtual base constructor
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>5.0
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>securesneakers@gmail.com
          </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=19653" name="attach_19653" title="Minimal example that reproduces the issue">attachment 19653</a> <a href="attachment.cgi?id=19653&action=edit" title="Minimal example that reproduces the issue">[details]</a></span>
Minimal example that reproduces the issue

Issue can be reproduced with attached example:

$ uname -s -m
Linux x86_64

$ clang++ --version
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ clang++ -std=c++11 -O2 minimal.cpp && ./a.out
Segmentation fault (core dumped)

Example contains class hierarchy similar to this:

struct alignas(16) Base1 { };
struct Base2 : virtual Base1 { };
struct Base3 : virtual Base2 { };

Clang assigns all three types alignment of 16 (alignas(T) equals 16). At the
same time Base2 is placed at offset 8 inside Base3 instance as it should be
according to Itanium ABI:
<a href="https://refspecs.linuxfoundation.org/cxxabi-1.75.html">https://refspecs.linuxfoundation.org/cxxabi-1.75.html</a>. This is due to
requirement that Base2 should be aligned by "non-volatile alignment" or
"nvalign" in ABI spec. So far everything seems to be correct and both Clang and
GCC generate identical layout for Base3.

The problem is that Clang tries to initialize member fields using "movaps"
instruction, using in with 8-byte aligned address, causing segfault. Seems that
optimizer checks "normal" type alignment when making a decision to use
"movaps", when "non-virtual" alignment should be used.</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>