[clang] [Clang][Sema] Promote pointers to common address space in pointer subtraction (PR #217341)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 21 08:58:01 PDT 2026


================
@@ -11902,6 +11902,37 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
                                                LHS.get(), RHS.get()))
         return QualType();
 
+      // For pointer subtraction, if the address spaces differ but overlap,
+      // convert both pointers to the composite (superset) address space.
+      // This is needed because pointer subtraction compares addresses, and
+      // addresses in different spaces may have different sizes.
----------------
addmisol wrote:

Updated.

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


More information about the cfe-commits mailing list