[cfe-dev] defaulted default constructor with initializer

Kal b17c0de at gmail.com
Thu Apr 16 23:33:45 PDT 2015


Am 17.04.15 um 01:48 schrieb Richard Smith:
> On Thu, Apr 16, 2015 at 10:16 AM, Kal <b17c0de at gmail.com 
> <mailto:b17c0de at gmail.com>> wrote:
>
>     Consider this code:
>
>     class A {
>     public:
>       struct I {
>         int i = 0;
>       };
>       A(I i = {}) {}
>     };
>
>     With clang 3.6 this doesn't compile:
>     4 : error: cannot use defaulted default constructor of 'I' within
>     'A' outside of member functions because 'i' has an initializer
>
>     But if I change the code to
>
>     class A {
>     public:
>       struct I {
>         int i = 0;
>         I() {}
>       };
>       A(I i = {}) {}
>     };
>
>     then the code compiles. Why is this so? Aren't these equivalent?
>
>
> 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.
You mean initializer for 'A::I' to have already been parsed? But hasn't 
the entire class definition for A::I and its initializers already been 
parsed before A::A?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150417/bc2abbbc/attachment.html>


More information about the cfe-dev mailing list