<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 16, 2015 at 10:16 AM, Kal <span dir="ltr"><<a href="mailto:b17c0de@gmail.com" target="_blank">b17c0de@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 bgcolor="#FFFFFF" text="#000000">
Consider this code:<br>
<br>
class A {<br>
public:<br>
struct I {<br>
int i = 0;<br>
};<br>
A(I i = {}) {}<br>
};<br>
<br>
With clang 3.6 this doesn't compile:<br>
4 : error: cannot use defaulted default constructor of 'I' within
'A' outside of member functions because 'i' has an initializer<br>
<br>
But if I change the code to<br>
<br>
class A {<br>
public:<br>
struct I {<br>
int i = 0;<br>
I() {}<br>
};<br>
A(I i = {}) {}<br>
};<br>
<br>
then the code compiles. Why is this so? Aren't these equivalent?</div></blockquote><div><br></div><div>They're not equivalent. The implicit constructor for A::I also has a deduced exception specification, and computing that exception specification requires the initializer for 'A::i' to have already been parsed.</div></div></div></div>