[cfe-dev] defaulted default constructor with initializer

Kal b17c0de at gmail.com
Thu Apr 16 10:16:00 PDT 2015


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?

Thanks,
Kal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150416/04205982/attachment.html>


More information about the cfe-dev mailing list