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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Without <string>:

#include <initializer_list>

int as;
struct A {
  A(const char *) { ++as; }
  A(const A&) { ++as; }
  ~A() { --as; }
};

void __attribute__((noipa))
tata(std::initializer_list<A> init)
{
  throw 1;
}

int
main()
{
  try { tata({ "foo","bar" }); }
  catch (...) { }

  if (as != 0) __builtin_abort ();
}



The problem is with the array EH cleanup handling: when we initialize an array
of a type with a non-trivial destructor, such as the backing array for the
initializer_list, we have a cleanup to destroy any constructed elements if a
later constructor throws.  But in this case the call to tata is still in that
region.  Without the r14-1705 change, we deal with that by disabling the array
cleanup in split_nonconstant_init, but with the change we don't go through
split_nonconstant_init and so we miss disabling the cleanup.

Reply via email to