<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 --- - [ms][EH] Clang cannot find appropriate catch statement for a throw"
href="https://llvm.org/bugs/show_bug.cgi?id=26787">26787</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ms][EH] Clang cannot find appropriate catch statement for a throw
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andrey.kuleshov@intel.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>!- Clang incorrectly works with EH on Windows and cannot find appropriate catch
statement for a throw function, all other compilers work correctly.
Moreover clang on Linux works correctly as well. This problem can be related to
incorrect work of function-try-block -!
=====Environment===========
OS: Windows
Lang: c++
=====Small Reproducer======
#include <stdio.h>
struct A {
~A () { throw 1; }
};
struct B : public A {
~B()
try { printf("B destructed\n"); }
catch(int j) { printf("Caught %d in ~B\n", j); }
};
int main()
{
try { B b; }
catch (int j) {}
return 0;
}
$ clang test.cpp -o out.exe
$./out.exe
=========Behavior==========
<span class="quote">>>> clang on Win:</span >
B destructed
$ echo $?
9
<span class="quote">>>> clang on Lin, gcc, MSVC, Intel icc:</span >
B destructed
Caught 1 in ~B
0
Andrey Kuleshov
=================
Software Engineer
Intel Compiler Team</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>