diff --git a/src/google/protobuf/any_test.cc b/src/google/protobuf/any_test.cc index 8b544d9eda..b367b89a36 100644 --- a/src/google/protobuf/any_test.cc +++ b/src/google/protobuf/any_test.cc @@ -63,6 +63,9 @@ TEST(AnyTest, TestPackAndUnpack) { } TEST(AnyTest, TestPackFromSerializationExceedsSizeLimit) { +#if defined(_MSC_VER) && defined(_M_IX86) + GTEST_SKIP() << "This toolchain can't allocate that much memory."; +#endif protobuf_unittest::TestAny submessage; submessage.mutable_text()->resize(INT_MAX, 'a'); protobuf_unittest::TestAny message; diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h index 6fa6423c0a..acba789811 100644 --- a/src/google/protobuf/generated_message_tctable_impl.h +++ b/src/google/protobuf/generated_message_tctable_impl.h @@ -583,7 +583,9 @@ class PROTOBUF_EXPORT TcParser final { template static inline T& RefAt(void* x, size_t offset) { T* target = reinterpret_cast(static_cast(x) + offset); -#ifndef NDEBUG +#if !defined(NDEBUG) && !(defined(_MSC_VER) && defined(_M_IX86)) + // Check the alignment in debug mode, except in 32-bit msvc because it does + // not respect the alignment as expressed by `alignof(T)` if (PROTOBUF_PREDICT_FALSE( reinterpret_cast(target) % alignof(T) != 0)) { AlignFail(std::integral_constant(), @@ -597,18 +599,7 @@ class PROTOBUF_EXPORT TcParser final { template static inline const T& RefAt(const void* x, size_t offset) { - const T* target = - reinterpret_cast(static_cast(x) + offset); -#ifndef NDEBUG - if (PROTOBUF_PREDICT_FALSE( - reinterpret_cast(target) % alignof(T) != 0)) { - AlignFail(std::integral_constant(), - reinterpret_cast(target)); - // Explicit abort to let compilers know this code-path does not return - abort(); - } -#endif - return *target; + return RefAt(const_cast(x), offset); } template