aboutsummaryrefslogtreecommitdiff
path: root/util/env_posix.cc
diff options
context:
space:
mode:
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)