[PATCH] D124571: Avoid strict aliasing violation on type punning inside llvm::PointerIntPair
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 12:14:45 PDT 2022
efriedma added a comment.
> No, wait... We can have a PunnedPointer<PointerIntPair<int*>>, and the constructor of PointerIntPair is not trivial, because it holds a PunnedPointer which does not have a trivial constructor. Back to the drawing board.
If you want to support calling getPointerAddress() in that case, then yes, I think you need to use placement new or a union. Anything that involves "implicitly creating objects" will only work with implicit-lifetime types.
In D124571#3495535 <https://reviews.llvm.org/D124571#3495535>, @brenoguim wrote:
>> [cstring.syn] says memcpy implicitly creates objects, so I think it's effectively the same result.
>
> @efriedma Do you have reference to that?
[cstring.syn] is a section in the standard? (You can search for the string "cstring.dyn" in the standard/a standard draft. Or online version: https://timsong-cpp.github.io/cppwp/cstring.syn .)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124571/new/
https://reviews.llvm.org/D124571
More information about the llvm-commits
mailing list