[cfe-commits] r171555 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp test/CodeGenObjC/arc-unoptimized-byref-var.m

Fariborz Jahanian fjahanian at apple.com
Fri Jan 4 17:19:34 PST 2013


On Jan 4, 2013, at 4:44 PM, John McCall wrote:

> On Jan 4, 2013, at 4:34 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
>> On Jan 4, 2013, at 3:56 PM, John McCall wrote:
>>>> 
>>> 
>>> You need to initialize the destination to null (with a simple store) before doing a storeStrong to it.
>> In r171572. This is I assume to prevent storeStrong from releasing the old value. I guess this should not happen
>> in this context,
> 
> Right.  objc_storeStrong is an assignment, not an initialization;  it reads the old value out of the destination and releases it.  When moving a __block variable to the heap, libclosure basically allocates some memory, sets up the byref header, and then checks whether there's a copy helper;  if there is, it invokes it immediately.  Therefore, when we're invoked, the destination address is freshly-allocated memory, and we cannot rely on it having been zero-initialized.

Makes sense. Thanks.
- Fariborz

> 
> John.
> 




More information about the cfe-commits mailing list