[hardware.interference] Bad examples of using alignas
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
Example 1 is the following:
struct keep_apart {
alignas(hardware_destructive_interference_size) atomic<int> cat;
alignas(hardware_destructive_interference_size) atomic<int> dog;
};
There is nothing specifying that these must be valid alignments, or that they must even be nonnegative integer powers of two. Would it make sense to use something like bit_ceil here, plus a check to handle the case where that result is not representable? That would fix the latter issue, not sure if it is possible to check if something is a valid alignment.
Example 2 is the following:
struct together {
atomic<int> dog;
int puppy;
};
struct kennel {
// Other data members...
alignas(sizeof(together)) together pack;
// Other data members...
};
static_assert(sizeof(together) <= hardware_constructive_interference_size);
Why is alignas(sizeof(together)) being done? The two issues mentioned above are also present here.
Contributor guide
No contributing guide indexed for this repository
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
Start with the two hardware interference examples quoted in the issue and review the surrounding standard-draft wording for alignas and alignment requirements. Determine whether the examples need valid-alignment handling and whether alignas(sizeof(together)) is justified. Done means the examples and their explanation no longer imply unsupported alignment assumptions, with the rationale for the second example made clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100