aboutsummaryrefslogtreecommitdiff
path: root/util/env_posix.cc
diff options
context:
space:
mode:
authorleveldb Team <no-reply@google.com>2025-01-08 18:54:39 +0000
committerVictor Costan <costan@google.com>2025-01-24 21:05:25 +0000
commit302786e211d1f2e6fd260261f642d03a91e5922c (patch)
tree0bc51fdc450086f3508455b16439dbc150fd6fe8 /util/env_posix.cc
parent578eeb702ec0fbb6b9780f3d4147b1076630d633 (diff)
downloadleveldb-302786e211d1f2e6fd260261f642d03a91e5922c.tar.gz
leveldb-302786e211d1f2e6fd260261f642d03a91e5922c.zip
Fix C++23 compilation errors in leveldb
Remove usages of std::aligned_storage, which is deprecated. More details about the replacement in https://crbug.com/388068052. PiperOrigin-RevId: 713346733
Diffstat (limited to 'util/env_posix.cc')
-rw-r--r--util/env_posix.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/util/env_posix.cc b/util/env_posix.cc
index ffd06c4..57c19ec 100644
--- a/util/env_posix.cc
+++ b/util/env_posix.cc
@@ -874,7 +874,11 @@ class SingletonEnv {
#endif // !defined(NDEBUG)
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
"env_storage_ will not fit the Env");
- static_assert(alignof(decltype(env_storage_)) >= alignof(EnvType),
+ static_assert(std::is_standard_layout_v<SingletonEnv<EnvType>>);
+ static_assert(
+ offsetof(SingletonEnv<EnvType>, env_storage_) % alignof(EnvType) == 0,
+ "env_storage_ does not meet the Env's alignment needs");
+ static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
"env_storage_ does not meet the Env's alignment needs");
new (&env_storage_) EnvType();
}
@@ -892,8 +896,7 @@ class SingletonEnv {
}
private:
- typename std::aligned_storage<sizeof(EnvType), alignof(EnvType)>::type
- env_storage_;
+ alignas(EnvType) char env_storage_[sizeof(EnvType)];
#if !defined(NDEBUG)
static std::atomic<bool> env_initialized_;
#endif // !defined(NDEBUG)