From 4ecf0a8d1fc045f779a7319307f3118e06dfea82 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 19 Jun 2025 18:04:05 +0800 Subject: [PATCH] rgw: avoid using std::aligned_storage_t std::aligned_storage_t was deprecated in C++23, to be prepared for it, let's use alignas for the same behavior. because the 3 * 8 (with LP64 data model) is not power-of-2, while `alignas()` requires an alignment of power of 2. so we use `std::bit_ceil()` to calculate the minimum alignment greater or equal to this number. Signed-off-by: Kefu Chai --- src/rgw/rgw_aio.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_aio.h b/src/rgw/rgw_aio.h index 0b4ce71ca3f6..4f6301c8f84f 100644 --- a/src/rgw/rgw_aio.h +++ b/src/rgw/rgw_aio.h @@ -15,9 +15,9 @@ #pragma once +#include #include #include -#include #include #include "include/rados/librados_fwd.hpp" @@ -40,7 +40,10 @@ struct AioResult { uint64_t id = 0; // id allows caller to associate a result with its request bufferlist data; // result buffer for reads int result = 0; - std::aligned_storage_t<3 * sizeof(void*)> user_data; + static constexpr size_t user_data_alignment = std::bit_ceil(3 * sizeof(void*)); + struct alignas(user_data_alignment) { + unsigned char data[user_data_alignment]; + } user_data; AioResult() = default; AioResult(const AioResult&) = delete; -- 2.47.3