<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:lebedev.ri@gmail.com" title="Roman Lebedev <lebedev.ri@gmail.com>"> <span class="fn">Roman Lebedev</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - [11 regression] Code segfaults with -O1 -mavx2"
href="https://bugs.llvm.org/show_bug.cgi?id=48591">bug 48591</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>lebedev.ri@gmail.com
</td>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - [11 regression] Code segfaults with -O1 -mavx2"
href="https://bugs.llvm.org/show_bug.cgi?id=48591#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - [11 regression] Code segfaults with -O1 -mavx2"
href="https://bugs.llvm.org/show_bug.cgi?id=48591">bug 48591</a>
from <span class="vcard"><a class="email" href="mailto:lebedev.ri@gmail.com" title="Roman Lebedev <lebedev.ri@gmail.com>"> <span class="fn">Roman Lebedev</span></a>
</span></b>
<pre><a href="https://godbolt.org/z/dq4xGz">https://godbolt.org/z/dq4xGz</a>
(In reply to Evan Nemerson from <a href="show_bug.cgi?id=48591#c0">comment #0</a>)
<span class="quote">> I have some code which has started segfaulting (often, but not reliably)
> when compiled with `clang-11 -O1 -mavx2`. clang-10 works reliably, as do
> other optimization levels.
>
> I (well, C-Reduce) have reduced it to the following:
>
> typedef long a __attribute__((__vector_size__(32)));
> a d, e;
> void b(a *p1) { __builtin_memcpy(p1, &d, sizeof(d)); }
> int main() {
> {
> {</span >
<span class="quote">> int c[sizeof(e) / sizeof(int)];
> b(({ (a *)c; }));</span >
This is UB.
`c` is only aligned as an `int` (4 bytes, even though it is effectively aligned
by 16 bytes),
yet you cast it to `a`, which is more strictly aligned (32 bytes).
<span class="quote">> }
> }
> }
> Here it is on Compiler Explorer: <<a href="https://godbolt.org/z/z8d6hK">https://godbolt.org/z/z8d6hK</a>>. The exit
> code for clang-11 is 139 for me now, but I can't promise it will be for you;
> as I mentioned it doesn't crash every time, and I'm pretty sure Compiler
> Explorer caches results. On my desktop it's crashing on ~52% of executions.
>
> This happens with a *lot* of the test cases in SIMDe
> (<<a href="https://github.com/simd-everywhere/simde">https://github.com/simd-everywhere/simde</a>>) if anyone wants to try
> reproducing with "real" code.</span ></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>