[cfe-dev] warn when ctor-initializer leaves uninitialized data?

Gabor Greif gabor at mac.com
Tue Apr 10 16:21:25 PDT 2012


Arthur O'Dwyer wrote:

> Here's one more semi-common idiom that we ran into at the time:
>
> Foo::Foo() {
>     memset(this, '\0', sizeof *this); // most of my fields should be
> false or zero
>     this->should_be_true = true; // initialize only the interesting  
> ones
> }


This should definitely warn if there is a vptr overwritten by the  
memset.

Cheers,

	Gabor




More information about the cfe-dev mailing list