llvm / llvm/llvm-project

[Clang] ABI mismatch between Clang and GCC when using vector types in a union

Open
#183,723 3 comments 0 reactions 0 assignees View on GitHub
ABI clang diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
template
using vec [[gnu::vector_size(N * sizeof(T))]] = T;

union S {
vec v;
vec w[4];
};

S test() {
return S{};
}
```
Clang and GCC disagree on whether the above code passes `S` in a register or on the stack.

Contributor guide

Open the contributing guide

Research direction

Start by compiling and inspecting the supplied C++ reproducer with both Clang and GCC, confirming how the union return value is passed. Then trace Clang's ABI handling for vector types in unions and add a regression test for the case. Done means Clang and GCC agree on whether S is passed in a register or on the stack.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.