<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-cl x86/Release inlined try-catch leads to access violation or std::length_error"
href="https://bugs.llvm.org/show_bug.cgi?id=47515">47515</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl x86/Release inlined try-catch leads to access violation or std::length_error
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ki.stfu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Hi! I use VS2019 16.7.2 with bundled LLVM/Clang 10.0.0, and I get AV or a
length_error & corrupted stack when compile the following code for x86/Release
using LLVM (clang-cl) toolset:
```
#include <new>
#define BOOST_ALL_NO_LIB
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp> // boost v1.73.0
//__declspec(noinline)
inline int to_code() noexcept
{
try {
throw;
}
catch (const std::bad_alloc& ) { return 1; }
catch (... ) { return 2; }
}
BOOST_AUTO_TEST_CASE(to_code_test) {
try {
throw std::bad_alloc();
} catch (const std::bad_alloc&) {
BOOST_TEST_CHECK(to_code() == 1);
}
}
```
__declspec(noinline) helps to avoid this, and I also can't reproduce it w/o
try-catch block.
1. Create Console App (C++) in VS2019
2. Paste the code above
3. Configure boost 1.73.0
4. Change toolset to LLVM (clang-cl)
5. Build and run x86/Release
I zipped .sln file with source code, preprocessed rethrow_inlined_test.i, and
x86_Release_libboost_unit_test_framework.lib I used in my project in case you
need it.</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>