[PATCH] D124571: Avoid strict aliasing violation on type punning inside llvm::PointerIntPair
Breno Rodrigues Guimaraes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 09:28:14 PDT 2022
brenoguim added inline comments.
================
Comment at: llvm/include/llvm/ADT/PointerIntPair.h:49
+
+ alignas(Ptr) char Data[sizeof(Ptr)];
+};
----------------
akyrtzi wrote:
> I believe this can just be `Ptr Data;`, it doesn't need to be a `char` buffer, the `memcpy`s should keep this in "defined behavior land" even if you are copying from a pointer type.
>
> Then `getPointerAddress()` becomes
> ```
> Ptr *getPointerAddress() { return &Data; }
> ```
True, I can't find any issue with that reasoning. I'll apply this change.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124571/new/
https://reviews.llvm.org/D124571
More information about the llvm-commits
mailing list