<html>
<head>
<base href="http://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 --- - Undefined behavior in v1/__tree and v1/list"
href="http://llvm.org/bugs/show_bug.cgi?id=19302">19302</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Undefined behavior in v1/__tree and v1/list
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>octoploid@yandex.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>While debugging a gold linker issue I came across the following
-fsanitize=undefined runtime error:
/usr/include/c++/v1/list:218:19: runtime error: downcast of address
0x7fffa93b8e88 with insufficient space for an object of type
'std::__1::__list_node<gold::Output_section::
Input_section, void *>'
0x7fffa93b8e88: note: pointer points here
00 00 00 00 50 94 3b a9 ff 7f 00 00 20 3b d1 02 00 00 00 00 00 00 00 81 ff
ff ff ff 01 00 00 00
^
/usr/include/c++/v1/list:219:19: runtime error: downcast of address
0x7fffa93b8e88 with insufficient space for an object of type
'std::__1::__list_node<gold::Output_section::
Input_section, void *>'
0x7fffa93b8e88: note: pointer points here
00 00 00 00 88 8e 3b a9 ff 7f 00 00 20 3b d1 02 00 00 00 00 00 00 00 81 ff
ff ff ff 01 00 00 00
^
/usr/include/c++/v1/list:592:25: runtime error: downcast of address
0x7fffa93b8ed0 with insufficient space for an object of type
'std::__1::__list_node<gold::Output_section::Input_section, void *>'
0x7fffa93b8ed0: note: pointer points here
ff 7f 00 00 30 2e 04 03 00 00 00 00 30 2e 04 03 00 00 00 00 01 00 00 00 00
00 00 00 70 89 65 03
^
/usr/include/c++/v1/__tree:834:16: runtime error: downcast of address
0x7fffa93b8e00 with insufficient space for an object of type
'std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >, gold::Output_segment
*>, void *>'
0x7fffa93b8e00: note: pointer points here
00 00 00 00 40 21 0a 03 00 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00
See: <a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031213.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031213.html</a>
for an analysis of the issue by Richard Smith.
Basically one should use use reinterpret_cast instead of static_cast to
avoid the undefined behavior.</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>