In C, using memset(0) is normal/common for initialization.
But in C++, typically we want value initialization. The constructor knows how to initialize that class.
This is because in C it is more common for value initialization to effectively set everything to 0.
A problem came up where a class was being initialized with memset(0) but that class had a base::Optional member with negative logic. storage_.is_null = true would indicate the optional had not been filled. memset(0) set it to false, which incorrectly indicated a filled optional.
base::Optional was updated to use affirmative storage_.is_populated_ rather than negative storage_.is_null_, which allowed memset(0) to work. But the correct solution is to stop using memset(0).
Comment 1 by bugdroid1@chromium.org
, Feb 7 2018