[Bug c++/91369] Implement P0784R7: constexpr new

lutztonineubert at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 6 15:47:00 GMT 2020


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

--- Comment #28 from Toni Neubert <lutztonineubert at gmail dot com> ---
Thank you very much again for your fast help. Your patch works for this test
case.

I have another test case which fails. (Maybe more..., I am sorry).

//main.cpp: in ‘constexpr’ expansion of ‘test3()’
//main.cpp: in ‘constexpr’ expansion of ‘(& b)->bar::~bar()’
//main.cpp: in ‘constexpr’ expansion of ‘(&((bar*)this)->bar::f)->foo::~foo()’
//main.cpp  error: deallocation of already deallocated storage
struct foo {
        constexpr foo(int* i) : ptr{i} {}

        constexpr ~foo() {
                delete ptr;
        }

        int* ptr;
};

struct bar {
        foo f{new int};
};

constexpr auto test3() {
        bar b;
        return true;
}

static_assert(test3());


More information about the Gcc-bugs mailing list