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

hyrosen at mail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hyrosen at mail dot com

--- Comment #9 from hyrosen at mail dot com ---
The storage for an object can still be accessible after the object is
destroyed.  Therefore, writes in the destructor should not be eliminated unless
they are provably inaccessible:

struct X { int i; ~X() { i = 0; } };

void destroy(X &x) { x.~X(); }

int main()
{
    alignas(X) char buf[sizeof(X)], save[sizeof(X)];
    X *x = new (buf) X;
    x->i = 1;
    memcpy(save, buf, sizeof(X));
    destroy(*x);
    assert(memcmp(buf, save, sizeof(X)) != 0);
}

Reply via email to