This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced from PR 64887:

struct string
{
  string(const char*) { }
  ~string(); // make this type non-trivial
};

struct A
{
  string s;
  A() = delete;
  A(const A&) = delete;
  A(A&&) = delete;
  A(const char*);
};

A arr[2] = {{"a"}, {"b"}}; // ok

struct Aggr {
  A arr[2];
  Aggr() : arr{{"a"}, {"b"}} {} // error
};

The member of non-trivial type is required to trigger the error, presumably
because it makes the destructor non-trivial.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]