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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |jason at gcc dot gnu.org
      Known to work|                            |8.3.0
      Known to fail|                            |10.0, 9.1.0

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is a wrong code bug too:

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();
}

free(): double free detected in tcache 2
Aborted (core dumped)

Reply via email to