New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P0528R3 The curious case of padding bits, featuring atomic compare-and-exchange #2154
Conversation
source/atomics.tex
Outdated
operations may result in failed comparisons for values that compare equal with | ||
\tcode{operator==} if the underlying type has padding bits, trap bits, or alternate | ||
\begin{note} | ||
Under cases where \tcode{memcpy} and \tcode{memcmp} semantics of the compare-and-exchange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "the" after "where"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// Padding here. | ||
unsigned biff = 0xC0DEFEFE; | ||
}; | ||
atomic<padded> pad = ATOMIC_VAR_INIT({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the Cism of ATOMIC_VAR_INIT
here and use = padded{}
or ({})
?
(I've also asked on LWG whether it's intended that atomic<padded> pad = {};
should work. But regardless of whether it should, that is not guaranteed today.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need ATOMIC_VAR_INIT until Nico's fix P0883R1 makes it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving as is then? We can change it later if that's appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think you should leave it as-is and editorially remove uses of ATOMIC_VAR_INIT when P0833R1 is voted in. This was discussed in CWG and people decided to keep ATOMIC_VAR_INIT in my paper for now. Of course the example isn't normative, so 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need P0833R1. That permits
atomic<padded> pad = {};
but either of the forms I suggested work fine without P0833, because they use the atomic(T) constructor, not the default constructor.
Still... if CWG wants the ATOMIC_VAR_INIT
, then let's leave it alone.
double celestia = 0.; | ||
short luna; // padded | ||
}; | ||
atomic<pony> princesses = ATOMIC_VAR_INIT({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
c940514
to
cd89182
Compare
Sorry, I force-pushed this one rather than making a new commit, because I had already rebased on the new master (even though for this branch that wasn't even necessary). I'll try to preserve commits in the future. |
…d-exchange Added a cross-reference for "padding bits".
cd89182
to
2dc7620
Compare
Added a cross-reference for "padding bits".
Fixes #2121.