[PATCH] D58236: Make address space conversions a bit stricter.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 27 10:27:53 PST 2019


efriedma added a comment.

Generally, with an explicit cast, C allows any pointer cast with a reasonable interpretation, even if the underlying operation is suspicious.  For example, you can cast an "long*" to a "int*" (as in "(int*)(long*)p") without any complaint, even though dereferencing the result is likely undefined behavior.  (C doesn't allow explicitly writing a reinterpret_cast, but that's basically the operation in question.)

Along those lines, in general, the normal C rules should allow casting `foo*` to `bar*` for any object types foo and bar, even if foo and bar are pointers with address spaces, like `__local int *` and `__global int *`.  I don't see anything in the OpenCL standard that would contradict this.  It looks like this patch changes that?

I agree we shouldn't allow implicit conversions, though...


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

https://reviews.llvm.org/D58236





More information about the cfe-commits mailing list