`<expected>`: Investigate reusing tail padding of the union
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Given [[msvc::no_unique_address]] landed in Clang 18, we can applied it to union members (possibly with the whole union) in expected.
E.g. in this example
struct IC {
int i;
char c;
};
std::expected<IC, int> e;
its possible to make sizeof(e) == 8 because the size of the union is 8, while the first 5 bytes are value bytes, and bool flag can live in the tail padding of the union.
We need to ensure that the tail padding won't be furtherly reused - otherwise, when the expected object is itself potentially-overlapping, reconstruction of a union member may overwrite the data not controlled by the implementation.
See also LLVM-68552, LLVM-68733, and LLVM-69673.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named; start by reading the expected implementation and the referenced LLVM-68552, LLVM-68733, and LLVM-69673 issues. Determine whether union tail padding can safely hold the flag and whether further reuse is prevented, then validate the proposed layout with the supplied IC example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100