[Bug c++/102167] New: Constexpr virtual destructors confuse memory leak detection during constant evaluation

friedkeenan at protonmail dot com gcc-bugzilla@gcc.gnu.org
Wed Sep 1 22:37:02 GMT 2021


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

            Bug ID: 102167
           Summary: Constexpr virtual destructors confuse memory leak
                    detection during constant evaluation
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: friedkeenan at protonmail dot com
  Target Milestone: ---

Minimal example:

struct S {
    virtual constexpr ~S() { }
};

consteval bool test() {
    const auto ptr = new S;
    delete ptr;

    return true;
}

static_assert(test());

Godbolt link: https://godbolt.org/z/6jszvsxGE

Clang handles the code correctly.

Possibly related to Bug 93413, which is the reason why the virtual destructor
is not defaulted, as doing so raises the error from that report.


More information about the Gcc-bugs mailing list