[hardware.interference] Bad examples of using alignas
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- cpp
- Domain
- documentation
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.
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.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 17h 45m
- Merged PRs (30d)
- 34
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.
More from cplusplus/draft
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
ub-ifndr
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
bisq-network/support#2181 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
tutorial updates Open
Difficulty 1/5 Under an hour Newbie friendliness 80/100
sveltejs/svelte.dev#2241 ·