[llvm-bugs] [Bug 35056] New: [ms] Broken codegen around SEH and __declspec(naked) inline asm

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 24 05:08:59 PDT 2017


            Bug ID: 35056
           Summary: [ms] Broken codegen around SEH and __declspec(naked)
                    inline asm
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org

C:\src\chrome\src>type foo.cc
#include <windows.h>

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

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

C:\src\chrome\src>cl /nologo foo.cc


C:\src\chrome\src>echo %errorlevel%

But with clang-cl:

foo.cc -m32

C:\src\chrome\src>foo  # This gives me "app has finished working" dialog

C:\src\chrome\src>echo %errorlevel%

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171024/5fa9992f/attachment.html>

More information about the llvm-bugs mailing list