Skip to content

[clang] Unreachable when -fwinx64-eh-unwindv2 is used on function with __finally block #196138

@eleviant

Description

@eleviant

Steps to reproduce:

  1. Create source file a.c
int bar();
void do_finalize();

int foo() {
  __try {
    while(1) {
      if (bar() == 42)
        break;
    }
  } __finally {
    do_finalize();
  }

  return 42;

}
  1. Compile with clang
clang-cl.exe -cc1 -triple x86_64-pc-windows-msvc19.50.35730 -emit-obj -funwind-tables=2 -target-cpu x86-64  -tune-cpu generic -fwinx64-eh-unwindv2 -cfguard   -fms-extensions  -o a.obj -x c a.c

Unreachable is fired in X86WinEHUnwindV2::runOnMachineFunction, because it's expecting frame SEH_PushReg to be in prolog, not in finally block

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other category

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions