diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 08ffbeb9..8631286b 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -402,11 +403,9 @@ class [[nodiscard]] MatcherBase : private MatcherDescriberInterface { template ()> 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(static_cast(&m.buffer_)); - return *ptr; + return *std::launder(reinterpret_cast(&m.buffer_)); } static void Init(MatcherBase& m, M impl) { ::new (static_cast(&m.buffer_)) M(impl);