<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 - clang segfault at -O2 in C mode, reduced test case included"
   href="https://bugs.llvm.org/show_bug.cgi?id=49716">49716</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang segfault at -O2 in C mode, reduced test case included
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>clang@evan.coeusgroup.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24690" name="attach_24690" title="Non-reduced, un-preprocessed source">attachment 24690</a> <a href="attachment.cgi?id=24690&action=edit" title="Non-reduced, un-preprocessed source">[details]</a></span>
Non-reduced, un-preprocessed source

Here is a reduced test case:


#include <stdlib.h>
typedef union {
  int16_t i16 __attribute__((__vector_size__(32)));
  int32_t i32 __attribute__((__vector_size__(32)));
} simde__m256i_private;
simde__m256i_private simde__m256i_to_private();
int simde_mm256_madd_epi16() {
  simde__m256i_private r_, a_ = simde__m256i_to_private(),
                           b_ = simde__m256i_to_private();
  for (size_t i = 0; i < sizeof sizeof(r_); i += 2)
    r_.i32[i] = a_.i16[i] * b_.i16[i] + a_.i16[i + 1] * b_.i16[i + 1];
  simde__m256i_from_private(r_);
}


Compile with -O2 using clang (clang++ works) on x86_64.  Godbolt link:
<a href="https://godbolt.org/z/71o5hdY4h">https://godbolt.org/z/71o5hdY4h</a>

The problem only manifests in my codebase with clang 12, but this test case
seems to reliably reproduce the issue in earlier versions as well (back to 7 on
godbolt).

I'm also attaching the original (non-reduced) source.  Please let me know if
you need any additional information.</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>