-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Remove workaround for lack of std::atomic_init #996
Conversation
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.
@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
From internal review, pedantically, this leaves the atomic in uninitialized state. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0883r0.pdf So |
Thanks for the paper link; I was not aware of this gotcha. It's a bit unfortunate the default initialization for atomics is broken IMO. I like Herb's quote of
In any case, I decided to switch to using an array of atomics and explicitly call |
Summary: - Since GCC 5 and later has `std::atomic_init`, remove the workaround present in `Tearable.h` to default initialize atomic variables. - Default initialization of atomics do not work as you would expect. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0883r0.pdf for the explanation why. - To get around the default initialization issue, we just call `std::atomic_init` for each element in the array of atomics.
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.
@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: - Since GCC 5 and later has `std::atomic_init`, remove the workaround present in `Tearable.h` to default initialize atomic variables. - Default initialization of atomics do not work as you would expect. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0883r0.pdf for the explanation why. - To get around the default initialization issue, we just call `std::atomic_init` for each element in the array of atomics. Pull Request resolved: facebook#996 Reviewed By: LeeHowes Differential Revision: D13648263 Pulled By: yfeldblum fbshipit-source-id: 6f3c84089f9158bc5c0ad5efac13d49ef69f1770
Summary:
std::atomic_init
, remove the workaroundpresent in
Tearable.h
to default initialize atomic variables.http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0883r0.pdf
for the explanation why.
std::atomic_init
for each element in the array of atomics.