[PATCH] D124571: Avoid strict aliasing violation on type punning inside llvm::PointerIntPair
John McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 14:59:37 PDT 2022
rjmccall added inline comments.
================
Comment at: llvm/include/llvm/ADT/PointerIntPair.h:49
+
+ alignas(Ptr) char Data[sizeof(Ptr)];
+};
----------------
brenoguim wrote:
> 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.
I think `Ptr` is not actually required to be a pointer type — for example, it can be another `PointerIntPair` — which might interfere with being able to just store a `Ptr`.
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