]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/static_ptr: pass an integer to alignas to fix GCC-11 build failure 64071/head
authorKefu Chai <tchaikov@gmail.com>
Fri, 20 Jun 2025 23:00:01 +0000 (07:00 +0800)
committerKefu Chai <tchaikov@gmail.com>
Fri, 20 Jun 2025 23:11:26 +0000 (07:11 +0800)
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 <tchaikov@gmail.com>
src/common/static_ptr.h

index af069222cdd9ab7b6a8a6cbf6f0a39ffde52b248..125b9700d9c3de2530a93f62cfcbb4d825243f5c 100644 (file)
@@ -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;