llvm / llvm/llvm-project

[Clang] Implementation divergence on uninitialized union

Open
#185,869 7 comments 0 reactions 0 assignees View on GitHub
c++ clang:frontend constexpr diverges-from:gcc diverges-from:msvc question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
struct S {
S() {}
};

union U {
constexpr U() {}
constexpr ~U() {}

S s;
};

constinit U u;
```
is accepted by Clang, but rejected by GCC and MSVC. Not sure who is correct here.

Contributor guide

Open the contributing guide

Research direction

Start by checking the C++ rules for constinit, constexpr union constructors and uninitialized union members, then compare the diagnostic and acceptance behavior across Clang, GCC and MSVC using the reproducer in the issue. No source file or test location is named; done means establishing which behavior is standard-conforming and identifying the compiler change or standards clarification needed.

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
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.