[PATCH] D151087: [Clang] Permit address space casts with 'reinterpret_cast' in C++

Bevin Hansson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 07:33:47 PDT 2023


ebevhan added a comment.

In D151087#4360606 <https://reviews.llvm.org/D151087#4360606>, @jhuber6 wrote:

> In D151087#4360577 <https://reviews.llvm.org/D151087#4360577>, @ebevhan wrote:
>
>> What would be the semantics of such an operation if the address spaces are disjoint? Or, if the underlying pointer widths aren't the same?
>
> It would most likely invalid, but I'm not asserting that `clang` should be responsible for diagnosing misuse in these cases. Especially because in generic freestanding C++ we don't have any language options to suggest the actual semantics.

That's fair. I would like clang to improve and formalize the semantics for generic address space behavior a bit, which was part of the point with D62574 <https://reviews.llvm.org/D62574>.  But there don't seem to be enough people who need something like it to make it happen.

Honestly, looking at the patch again does suggest to me that your use case would be covered. It just wouldn't be done with a reinterpret_cast, but an addrspace_cast. Since every target by default would permit explicit casts with isExplicitAddrSpaceConversionLegal, your desired behavior should work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151087/new/

https://reviews.llvm.org/D151087



More information about the cfe-commits mailing list