[PATCH] D80317: [SYCL] Prohibit arithmetic operations for incompatible pointers
Anastasia Stulova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 20 14:18:44 PDT 2020
Anastasia added subscribers: jeroen.dobbelaere, rjmccall.
Anastasia added inline comments.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:10090
// if both are pointers check if operation is valid wrt address spaces
- if (S.getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
+ if ((S.getLangOpts().OpenCL || S.getLangOpts().SYCLIsDevice) &&
+ isLHSPointer && isRHSPointer) {
----------------
bader wrote:
> Alternative approach would be to remove `S.getLangOpts().OpenCL` to enable this check for all modes.
>
> @Anastasia, do you know if it's safe to do?
If I look at embedded C (ISO/IEC TR 18037) s5.3 rules that we are following largely in Clang I believe this is a universal rule!
Especially looking at the followong statement:
> Clause 6.5.6 - Additive operators, add another constraint paragraph:
> For subtraction, if the two operands are pointers into different address spaces, the address spaces must overlap.
So I think that it should apply to at least OpenCL, C and C++. I am surprised though that this has not been fixed yet.
I am CCing @rjmccall and @jeroen.dobbelaere in case they have any more insights on this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80317/new/
https://reviews.llvm.org/D80317
More information about the cfe-commits
mailing list