Skip to content

Commit e5d6aaf

Browse files
committed
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 73399b0 when std::aligned_storage_t was replaced with alignas. Signed-off-by: Kefu Chai <[email protected]>
1 parent 6771fb5 commit e5d6aaf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/common/static_ptr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class static_ptr {
101101
// difference in semantics between a pointer-to-const and a const
102102
// pointer.
103103
//
104-
mutable struct alignas(std::bit_ceil(Size)) {
104+
static constexpr std::size_t Alignment = std::bit_ceil(Size);
105+
mutable struct alignas(Alignment) {
105106
unsigned char data[sizeof(Base)];
106107
} buf;
107108

0 commit comments

Comments
 (0)