<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jun 23, 2014 at 10:51 AM, Kuba Břečka <span dir="ltr"><<a href="mailto:kuba.brecka@gmail.com" target="_blank">kuba.brecka@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div>I would like to ask about the difference in behavior of C++11 explicit constructors, between Clang/LLVM 3.4 and current trunk version (3.5). The following:</div>
<div><br></div><div><div><div>  #include <stdio.h></div>
<div>  struct Inner {</div><div>    explicit Inner() {}</div><div>  };</div><div>  struct Outer {</div><div>    Inner member;</div><div>  };</div><div>  int main() {</div><div>    Outer s = {};</div><div>    printf("%p\n", &s); // just to silence "unused variable" warning</div>

<div>    return 0;</div><div>  }</div></div></div><div><br></div><div>compiles fine with Clang 3.4 using "clang++ -std=c++11 -Wall -Wpedantic", however using trunk version, this gives me "chosen constructor is explicit in copy-initialization" error. Is this the right (intended) behavior?</div>
</div></blockquote><div><br></div><div>Yes. This reflects a recent bugfix to the C++ specification. Note that:</div><div><br></div><div>  Inner s = {};</div><div><br></div><div>was rejected before and after this change, as was</div>
<div><br></div><div>  Inner s = { {} };</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>How can you zero-initialize such an object? I mean "Outer s = Outer{}" doesn't compile either.</div>
</div></blockquote><div><br></div><div>  Outer s = Outer();</div><div><br></div><div>should work. In this case,</div><div><br></div><div>  Outer s;</div><div><br></div><div>should work fine too.</div></div></div></div>