Skip to content

Commit

Permalink
Use UB impl of launder on when using clang < 8 and c++17
Browse files Browse the repository at this point in the history
libstdc++'s definition of std::launder places it behind a check for
__builtin_launder, which is not available before clang 8.

Fixes: #1309
  • Loading branch information
glandium committed May 17, 2023
1 parent c8b33b0 commit d2ed049
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion absl/functional/internal/any_invocable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
(!defined(__clang__) || ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(8, 0))
return *std::launder(reinterpret_cast<T*>(&state->storage));
#elif ABSL_HAVE_BUILTIN(__builtin_launder)
return *__builtin_launder(reinterpret_cast<T*>(&state->storage));
Expand Down

0 comments on commit d2ed049

Please sign in to comment.