[cfe-dev] Question about arrays in blocks

jahanian fjahanian at apple.com
Wed Jun 19 11:32:24 PDT 2013


It is an efficiency issue. It requires copying entire array into the block descriptor.
- Fariborz

On Jun 19, 2013, at 2:53 AM, "Adler, Arik" <arik.adler at intel.com> wrote:

>  
> I am now testing blocks usage in OpenCL.
> I noticed that Clang forbids using an arrays within blocks (Clang forbid array capturing)
>  
> For Example, the following code will fail to compile because there is a reference to an array within a block.
> But if the line referring to block will comment out and the line with reference to integer pointer ('j') will comment in, the code will pass.
>  
> void block_arr()
> {
>   int res = 0;
>   int i[4] = { 3, 4, 4, 1 };
>   int* j = i;
>  
>   int (^test_block )(int) = ^(int num)
>     {
>       return num + i[1];      // This is an error: "error: cannot refer to declaration with an array type inside block"
> //      return num + j[1];    // This would work
>     };
>  
>     res = test_block(7);
> }
>  
>  
> Do you know what is the reason behind this limitation?
> And why it is possible to use a regular pointers but arrays are forbidden?
>  
> Thanks,
> Arik
> ---------------------------------------------------------------------
> Intel Israel (74) Limited
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130619/c4834d08/attachment.html>


More information about the cfe-dev mailing list