https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91369
--- Comment #25 from Toni Neubert <lutztonineubert at gmail dot com> ---
I get: "deallocation of already deallocated storage" for test2() but compiling
just test1() or test2() is just fine.


struct a {
        constexpr a(int* i) : i{i} {
        }
        constexpr ~a() {
                delete[] i;
        }
        int* i;
};

constexpr a make_a(int size) {
        return {new int[size]()};
}

constexpr bool test1() {
        make_a(1);
        return true;
}

constexpr bool test2() {
        make_a(1);
        return true;
}

static_assert(test1());
static_assert(test2());

Reply via email to