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

            Bug ID: 123030
           Summary: [4.9 Regression] [accepts-invalid] no error for
                    calling a deleted destructor in array new
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richard-gccbugzilla at metafoo dot co.uk
  Target Milestone: ---

Testcase:

int n;
struct Y {
  Y() { if (++n == 2) throw "oops"; }
  ~Y() = delete;
};

int main() {
  try {
    new Y[2];
  } catch (...) {}
}

This should be rejected: the array new expression should call the Y destructor
when the second construction throws, and the destructor is deleted. GCC
correctly calls the destructor if it's not deleted, but if it is deleted, the
code is accepted and silently misbehaves instead.
  • [Bug c++/123030] New... richard-gccbugzilla at metafoo dot co.uk via Gcc-bugs

Reply via email to