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

--- Comment #47 from Christopher Nerz <Christopher.Nerz at de dot bosch.com> ---
But shouldn't both give the same value?
The return of the new and the std::launder(...) point to the same object and
are both equal read-operations! It is imho not predictable that they behave
differently.

Note that I could construct the same behavior when creating a std::byte array
(within a complex structure) in which a (trivially copy, move, default
constructible (and destructable)) object is created via new, then the
surrounding complex structure is copied and then the copied byte array read as
this kind of object. So rougly

```
struct data { std::byte mem[8]; }

data d1;
new (d1.mem) long{5};
data d2 = std::move(d1);
*std::launder<long*>(reinterpret_cast<long*>(d2.mem));
```

not literally that code (that one is working), but conceptionally the same
thing.
I have to check whether NRVO in our code removes the move...

Reply via email to