<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 - [ms] Broken codegen around SEH and __declspec(naked) inline asm"
href="https://bugs.llvm.org/show_bug.cgi?id=35056">35056</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ms] Broken codegen around SEH and __declspec(naked) inline asm
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>enhancement
</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>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>C:\src\chrome\src>type foo.cc
#include <windows.h>
__declspec(naked)
bool SafeTerminateProcess(HANDLE process, UINT exit_code) {
__asm {
push ebp
mov ebp, esp
push [ebp+12]
push [ebp+8]
call TerminateProcess
test eax, eax
setne al
mov esp, ebp
pop ebp
ret
}
}
double g() { return 0.0; }
int main() {
__try {
volatile int* p = 0;
*p = 4;
} __except(1) {
SafeTerminateProcess(GetCurrentProcess(), 1);
}
}
This works in MSVC:
C:\src\chrome\src>where cl
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\Hostx86\x86\cl.exe
C:\src\chrome\src>cl /nologo foo.cc
foo.cc
C:\src\chrome\src>foo
C:\src\chrome\src>echo %errorlevel%
1
But with clang-cl:
C:\src\chrome\src>"third_party\llvm-build\Release+Asserts\bin\clang-cl.exe"
foo.cc -m32
C:\src\chrome\src>foo # This gives me "app has finished working" dialog
C:\src\chrome\src>echo %errorlevel%
-1073741819</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>