Issue 146973
Summary [aarch64][win] Applying alignment to a stack object causes a mis-compilation when using exception on Arm64 Windows
Labels backend:AArch64, platform:windows
Assignees
Reporter dpaoliello
    Given the following code:

```cpp
// Large object: alignment seems to be important?
struct alignas(128) BigObj {
    int value;
    // Destructor so it's kept alive.
    ~BigObj() { }
};

// Exception type need to be large enough to not fit in a register.
struct Error {
    int value;
 int padding[3];
};

int main() {
    BigObj bo{};

    try {
 throw Error { 42, {0, 0, 0} };
    } catch (const Error& e) {
 return e.value;
    }
    return 0;
}
```

This program crashes when built and run on Arm64 Windows:
```pwsh
> & 'C:\Program Files\LLVM\bin\clang.exe' .\test.cpp
> .\a.exe
> $LASTEXITCODE
-1073741819
```

The `alignas` seems to be important: if I remove that and replace it with a very large array within `BigObj` then the issue no longer reproduces.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to