Skip to content
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

Use UB impl of launder on when using clang < 8 and c++17 #1448

Merged
merged 1 commit into from
May 18, 2023

Conversation

glandium
Copy link
Contributor

libstdc++'s definition of std::launder places it behind a check for __builtin_launder, which is not available before clang 8.

Fixes: #1309

@google-cla
Copy link

google-cla bot commented May 17, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -197,7 +197,8 @@ union TypeErasedState {
template <class T>
T& ObjectInLocalStorage(TypeErasedState* const state) {
// We launder here because the storage may be reused with the same type.
#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed patch works in my testing, but I think I more principled thing to do would be to use #if __cpp_lib_launder >= 201606L. This seems to produce the same result when I try it on godbolt.

https://godbolt.org/z/sGezba1b9

libstdc++'s definition of std::launder places it behind a check for
__builtin_launder, which is not available before clang 8.

Fixes: abseil#1309
@copybara-service copybara-service bot merged commit f6f65f9 into abseil:master May 18, 2023
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 19, 2023
ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this pull request May 23, 2023
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Sep 29, 2023
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std::launder was not implemented in clang until version 6
2 participants