Fix speculatively some "placement new" issues in leveldb

cl/713346733 changed the type of some variables to pointers, but didn't adjust the placement new statements. From pkasting@: "I suspect your code is wrong and will crash. An array is a pointer, so taking its address also gives a pointer, which is why it compiles; but the value of that pointer is different. You're no longer providing the address of the storage, but rather the address of the array pointer."

PiperOrigin-RevId: 717926210
This commit is contained in:
leveldb Team 2025-01-21 16:19:03 +00:00 committed by Victor Costan
parent 302786e211
commit e829478c6a
3 changed files with 3 additions and 3 deletions

View File

@ -880,7 +880,7 @@ class SingletonEnv {
"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();
new (env_storage_) EnvType();
}
~SingletonEnv() = default;

View File

@ -775,7 +775,7 @@ class SingletonEnv {
"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();
new (env_storage_) EnvType();
}
~SingletonEnv() = default;

View File

@ -28,7 +28,7 @@ class NoDestructor {
static_assert(
alignof(NoDestructor<InstanceType>) % alignof(InstanceType) == 0,
"instance_storage_ does not meet the instance's alignment requirement");
new (&instance_storage_)
new (instance_storage_)
InstanceType(std::forward<ConstructorArgTypes>(constructor_args)...);
}