From: Kefu Chai Date: Fri, 20 Jun 2025 23:00:01 +0000 (+0800) Subject: common/static_ptr: pass an integer to alignas to fix GCC-11 build failure X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e5d6aaf97bca184bf2cb8d3ac9039847ed03a62d;p=ceph.git 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 --- 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;