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

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 28 03:00:07 PST 2019

Anastasia added a comment.

> 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?

s6.5 of OpenCL spec is very explicit about this case: "A pointer  to  address  space  A  can  only  be  assigned  to  a  pointer  to  the  same  address  space  A  or  a pointer  to  the  generic  address  space.  Casting  a  pointer  to  address  space  A  to  a  pointer  to  address space B is illegal if A and B are named address spaces and A is not the same as B". Although there is a typo with missing first occurrence of B.

The behavior with generic is explained in s6.5.5.

Btw, this patch doesn't change anything in the address space conversions of pointers in OpenCL in general but just changes the behavior of nested pointers for which spec doesn't say anything. I think trying to reject code that is doing something dangerous is a good thing!



More information about the cfe-commits mailing list