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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced example showing double free, which started with the same revision as
the ICE:

extern "C" void* malloc(decltype(sizeof(0)));
extern "C" void free(void*);

struct string {
  string(int) : s(malloc(1)) { }
  ~string() { free(s); }
  string(const string& str) : s(str.s ? malloc(1) : nullptr) { }
  void* s;
  bool empty() const { return s == nullptr; }
};

string foo()
{
  string s(42);
  return s.empty() ? throw "empty" : s;
}

int main()
{
  foo();
}

Reply via email to