diff --git a/src/node_snapshotable.h b/src/node_snapshotable.h index 18ef5fbd43fd..a9050877a04d 100644 --- a/src/node_snapshotable.h +++ b/src/node_snapshotable.h @@ -44,8 +44,11 @@ struct InternalFieldInfoBase { template T> static T* New(EmbedderObjectType type) { void* buf = ::operator new[](sizeof(T)); - memset(buf, 0, sizeof(T)); // Make the padding reproducible. T* result = new (buf) T; + // Zero the padding to make the bytes handed to V8 reproducible. Must come + // after the placement new, or -flifetime-dse drops it as a dead store. + // https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fno-lifetime-dse + memset(static_cast(result), 0, sizeof(T)); result->type = type; result->length = sizeof(T); return result;