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

Arthur O'Dwyer arthur at push.am
Tue Apr 10 10:20:09 PDT 2012

On Mon, Apr 9, 2012 at 17:04 PM, Nico Weber <thakis at chromium.org> wrote:
> this sounds like a really cool warning. I tried building chromium with
> it, here are a few examples where it warns but probably shouldn't:
[initializing a char array with strlcpy or strcpy]
[calling a helper method to initialize the members]
[using assignment statements in the body of the constructor]

This warning has the potential to get really messy if you try to
handle all possible cases.</stating-the-obvious> I know because I
implemented something exactly like this in (a proprietary fork of) the
EDG front-end a few years ago. Not saying you shouldn't try, just
saying it wasn't fun trying (and failing) to make it foolproof.

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


More information about the cfe-dev mailing list