[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 18 08:25:31 PDT 2024


zygoloid wrote:

> How about:
> [...]

Yeah, I think that fixes it. For me that looks a lot less simple than using a union, but it is nice to have only a single implementation. I'd be fine with going in that direction.

For CHERI, can we assume that the least-significant byte of the pointer representation is even when the alignment of the type is > 1?

> The std::launder may be unnecessary

Formally I think it's correct and necessary for the pointer and integer case because an array element and an object for which the array provides storage are not pointer-interconvertible, but it's incorrect for the `unsigned char` case because there's no in-lifetime `unsigned char` object at the provided address.

https://github.com/llvm/llvm-project/pull/111995


More information about the cfe-commits mailing list