<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - Segfault when move-assigning a std::map with an aligned Key"
href="https://llvm.org/bugs/show_bug.cgi?id=30449">30449</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Segfault when move-assigning a std::map with an aligned Key
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gael.guennebaud@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following example segfault with clang 3.8 and 3.9 when compiling with -O2
or -O3 (but runs fine with clang 3.7 and gcc):
#include <iostream>
#include <map>
struct alignas(16) Foo { int val; };
int main() {
std::map<int, Foo> m;
std::map<int, Foo> n{{1,{1}}};
std::cout << "GOT HERE" << std::endl;
m = std::move(n); // segfault happens here
std::cout << "GOT HERE TOO" << std::endl;
}
Removing "alignas(16)" or "std::move" disables the issue.
Finally, here is the backtrace:
frame #0: 0x00000001000014f5 a.out`main [inlined]
std::__1::__tree<std::__1::__value_type<int, Foo>,
std::__1::__map_value_compare<int, std::__1::__value_type<int, Foo>,
std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int,
Foo> > >::__move_assign(this=<unavailable>) + 67 at __tree:1350 [opt]
frame #1: 0x00000001000014b2 a.out`main [inlined]
std::__1::__tree<std::__1::__value_type<int, Foo>,
std::__1::__map_value_compare<int, std::__1::__value_type<int, Foo>,
std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int,
Foo> > >::operator=(this=<unavailable>) at __tree:1409 [opt]
frame #2: 0x00000001000014b2 a.out`main [inlined] std::__1::map<int, Foo,
std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, Foo> >
<span class="quote">>::operator=(this=<unavailable>) at map:961 [opt]</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>