Statically assert pointer alignment.

We use the lower bits for tagging.

PiperOrigin-RevId: 619606723
pull/16299/head
Chris Kennelly 10 months ago committed by Copybara-Service
parent 2693af92b3
commit 9b2b61cfb4
  1. 3
      src/google/protobuf/arenastring.h

@ -184,6 +184,9 @@ class PROTOBUF_EXPORT TaggedStringPtr {
private:
static inline void assert_aligned(const void* p) {
static_assert(kMask <= alignof(void*), "Pointer underaligned for bit mask");
static_assert(kMask <= alignof(std::string),
"std::string underaligned for bit mask");
ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL);
}

Loading…
Cancel
Save