Merge 9fec814a9a1459b88fec7b569db99ccb12d5362b into 7140cd416cecd7462a8aae488024abeee55598e4

This commit is contained in:
Omer Ozarslan 2026-06-11 19:28:11 +02:00 committed by GitHub
commit db2b8d188e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,6 +43,7 @@
#include <cstddef>
#include <functional>
#include <memory>
#include <new>
#include <ostream>
#include <string>
#include <type_traits>
@ -403,11 +404,9 @@ class [[nodiscard]] MatcherBase : private MatcherDescriberInterface {
template <typename M, bool = MatcherBase::IsInlined<M>()>
struct ValuePolicy {
static const M& Get(const MatcherBase& m) {
// When inlined along with Init, need to be explicit to avoid violating
// When inlined along with Init, need to be laundered to avoid violating
// strict aliasing rules.
const M* ptr =
static_cast<const M*>(static_cast<const void*>(&m.buffer_));
return *ptr;
return *std::launder(reinterpret_cast<const M*>(&m.buffer_));
}
static void Init(MatcherBase& m, M impl) {
::new (static_cast<void*>(&m.buffer_)) M(impl);