<br><br><div class="gmail_quote">Le 10 avril 2012 19:20, Arthur O'Dwyer <span dir="ltr"><<a href="mailto:arthur@push.am">arthur@push.am</a>></span> a écrit :<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Mon, Apr 9, 2012 at 17:04 PM, Nico Weber <<a href="mailto:thakis@chromium.org">thakis@chromium.org</a>> wrote:<br>
><br>
> this sounds like a really cool warning. I tried building chromium with<br>
> it, here are a few examples where it warns but probably shouldn't:<br>
</div>[initializing a char array with strlcpy or strcpy]<br>
[calling a helper method to initialize the members]<br>
[using assignment statements in the body of the constructor]<br>
<br>
This warning has the potential to get really messy if you try to<br>
handle all possible cases.</stating-the-obvious> I know because I<br>
implemented something exactly like this in (a proprietary fork of) the<br>
EDG front-end a few years ago. Not saying you shouldn't try, just<br>
saying it wasn't fun trying (and failing) to make it foolproof.<br>
<br>
Here's one more semi-common idiom that we ran into at the time:<br>
<br>
Foo::Foo() {<br>
    memset(this, '\0', sizeof *this); // most of my fields should be<br>
false or zero<br>
    this->should_be_true = true; // initialize only the interesting ones<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
-Arthur</font></span><br></blockquote></div><br>Perhaps that as a first approach it would be simpler to just not warn whenever there is at least one statement in the constructor's body ?<br><br>This is also a common pattern in C++03 because of the absence of delegating constructors:<br>
<br>class A {<br>public:<br>   A() { this->init(0); }<br>   A(int x) { this->init(x); }<br>...<br>};<br><br>And the definition of "init" might not be available.<br>