C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[packed]] std::unaligned

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 19 Dec 2023 19:42:34 +0000
On Tue, Dec 19, 2023 at 7:33 PM Jason McKesson via Std-Proposals wrote:
>
> If an object contains a pointer into itself, relocating it *period* is
> a problem. It doesn't matter what type the pointer is of; you can't
> just do a memcpy and expect to get reasonable results out the other
> end, since the pointer will be pointing back into the old former
> object that no longer exists.


Hence why I adjust the pointer on Line #62 of this GodBolt:
https://godbolt.org/z/8TYs79fjh for the libstdc++ implementation of
std::string that contains a pointer to itself.

Received on 2023-12-19 19:42:26