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

--- Comment #9 from Alexander Cherepanov <ch3root at openwall dot com> ---
DR 1116 is said to be resolved by P0137R1[1]. By looking through it, I don't
see how it covers testcases from this pr where "right" pointer is used (like
the example in comment 0). And it even introduces std::launder for using
"wrong" pointers.

Even better, the C++ standard contains a whole paragraph ([basic.life]p9 -- see
[2]) describing finer details of killing non-dynamic variables. And the example
there features exactly placement new over a local variable:

----------------------------------------------------------------------
class T { };
struct B {
   ~B();
};

void h() {
   B b;
   new (&b) T;
}                               // undefined behavior at block exit
----------------------------------------------------------------------

The examples in this pr don't have classes with non-trivial destructors so they
don't hit such UB.

[1] http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0137r1.html
[2] https://eel.is/c++draft/basic.life#9

Reply via email to