mirror of
https://github.com/google/leveldb.git
synced 2025-01-27 06:30:07 +08:00
UB: reinterpret_cast pointer without using launder
Signed-off-by: wineway <wangyuweihx@gmail.com>
This commit is contained in:
parent
068d5ee1a3
commit
e40943c945
@ -39,6 +39,12 @@
|
||||
#endif // defined(DeleteFile)
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#ifdef __cpp_lib_launder
|
||||
#define LAUNDER(x) std::launder((x))
|
||||
#else
|
||||
#define LAUNDER(x) x
|
||||
#endif
|
||||
|
||||
namespace leveldb {
|
||||
|
||||
class FileLock;
|
||||
|
@ -883,7 +883,7 @@ class SingletonEnv {
|
||||
SingletonEnv(const SingletonEnv&) = delete;
|
||||
SingletonEnv& operator=(const SingletonEnv&) = delete;
|
||||
|
||||
Env* env() { return reinterpret_cast<Env*>(&env_storage_); }
|
||||
Env* env() { return LAUNDER(reinterpret_cast<Env*>(&env_storage_)); }
|
||||
|
||||
static void AssertEnvNotInitialized() {
|
||||
#if !defined(NDEBUG)
|
||||
|
@ -778,7 +778,7 @@ class SingletonEnv {
|
||||
SingletonEnv(const SingletonEnv&) = delete;
|
||||
SingletonEnv& operator=(const SingletonEnv&) = delete;
|
||||
|
||||
Env* env() { return reinterpret_cast<Env*>(&env_storage_); }
|
||||
Env* env() { return LAUNDER(reinterpret_cast<Env*>(&env_storage_)); }
|
||||
|
||||
static void AssertEnvNotInitialized() {
|
||||
#if !defined(NDEBUG)
|
||||
|
Loading…
Reference in New Issue
Block a user