Different address space elements in structs/unions

Discussion created by nooploop on Feb 8, 2011
Latest reply on Feb 8, 2011 by MicahVillmow


reading the restrictions of OpenCL i came across this:

Elements of a struct or union must belong to the same address space. Declaring a struct or union whose elements are in different address spaces is illegal.

So i went and tried the attached code. And the compiler didnt complained. Shouldn't this code be rejected, or atleast shouldn't i get a warning? Or i'm completly wrong and missing something?


union glp { __local int *l; __global int *g; }; struct sglp { __local int *l; __global int *g; }; __kernel void func() { struct sglp x; x.l = 0; x.g = 0; union glp y; y.l = 0; y.g = 0; }