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>
// 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;