[cfe-dev] Question about arrays in blocks

Adler, Arik arik.adler at intel.com
Wed Jun 19 23:38:12 PDT 2013


Does Clang supposed to disallow such feature for the sake of efficiency?
Isn't a warning message will be more suitable in this case?


From: jahanian [mailto:fjahanian at apple.com]
Sent: Wednesday, June 19, 2013 21:32
To: Adler, Arik
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Question about arrays in blocks

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<mailto: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<mailto:cfe-dev at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

---------------------------------------------------------------------
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130620/063bc801/attachment.html>


More information about the cfe-dev mailing list