[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
Tue May 3 12:27:12 PDT 2022
efriedma added a comment.
> This is a reduced version of the issue: https://godbolt.org/z/zor6MhPT6
> I was wrong. This only miscompiles only on clang 11, 12 and 13. It works fine on clang <v10 and on clang 14.
That looks like a globalopt bug. I remember there was a patch in LLVM 14 related to this; I don't think it's something you can reasonably work around.
--------
I think strictly speaking, to avoid UB you might need to declare "Data" as a union: otherwise, the compiler might assume the value it contains is aligned. I don't think clang does, in practice, but probably you want to be conservative.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124571/new/
https://reviews.llvm.org/D124571
More information about the llvm-commits
mailing list