From e5d6aaf97bca184bf2cb8d3ac9039847ed03a62d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 21 Jun 2025 07:00:01 +0800 Subject: [PATCH] common/static_ptr: pass an integer to alignas to fix GCC-11 build failure GCC-11 fails to compile `alignas(std::bit_ceil(Size))` despite std::bit_ceil() being marked constexpr in libstdc++11. The compiler doesn't recognize it as a constant expression, while GCC-12+ and Clang-14+ handle it correctly. Define the alignment value as a separate constexpr variable before passing it to alignas() to ensure compatibility with GCC-11. Fixes compilation issue introduced in commit 73399b05 when std::aligned_storage_t was replaced with alignas. Signed-off-by: Kefu Chai --- src/common/static_ptr.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/static_ptr.h b/src/common/static_ptr.h index af069222cdd9a..125b9700d9c3d 100644 --- a/src/common/static_ptr.h +++ b/src/common/static_ptr.h @@ -101,7 +101,8 @@ class static_ptr { // difference in semantics between a pointer-to-const and a const // pointer. // - mutable struct alignas(std::bit_ceil(Size)) { + static constexpr std::size_t Alignment = std::bit_ceil(Size); + mutable struct alignas(Alignment) { unsigned char data[sizeof(Base)]; } buf; -- 2.47.3