[cfe-commits] r65751 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp test/CodeGenObjC/blocks-unsupported.m
Anders Carlsson
andersca at mac.com
Sun Mar 1 12:22:45 PST 2009
On Mar 1, 2009, at 11:06 AM, Mike Stump wrote:
> On Mar 1, 2009, at 10:55 AM, Anders Carlsson wrote:
>> __block variables don't work. For example
>>
>> void f()
>> {
>> __block int a = 10;
>>
>> ^{
>> a = 20;
>> }();
>>
>> printf("a is: %d\n", a);
>> }
>>
>> does not work as expected.
>
> Do you expect something different? :-(
I did not! :) That's good news!
However, __block variables are still allocated on the stack, even when
copied. For example:
int
main(int argc, char **argv)
{
__block int a;
printf("a is: %p\n", &a);
Block_copy(^{ printf("block: a is: %p\n", &a);})();
return 0;
}
gives
a is: 0x7fff5fbff7a0
block: a is: 0x1001001b8
with llvm-gcc, but
a is: 0x7fff5fbff7fc
block: a is: 0x7fff5fbff7fc
with clang. I'd rather that we error on __block variables instead of
miscompiling.
Anders
More information about the cfe-commits
mailing list