[Bug c++/63707] Brace initialization of array sometimes fails if no copy constructor

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 28 11:52:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63707

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The member array case only fails when the array element has a user-defined
destructor

Here's the failing testcase repeated from the attachment and reduced slightly:

struct Child
{
    Child (int);
    ~Child ();
    Child (const Child &) = delete;
};

struct Parent
{
    Parent () : children {{5}, {7}} {}

    Child children[2];
};


i.cc: In constructor ‘Parent::Parent()’:
i.cc:12:35: error: use of deleted function ‘Child::Child(const Child&)’
     Parent () : children {{5}, {7}} {}
                                   ^
i.cc:6:5: note: declared here
     Child (const Child &) = delete;
     ^

Commenting out the destructor declaration allows it to compile.


More information about the Gcc-bugs mailing list