dexonsmith added a comment.

In D58514#1428520 <https://reviews.llvm.org/D58514#1428520>, @ahatanak wrote:

> That code doesn't crash because the block is retained at the entry of `bar` 
> and ARC optimizer doesn't remove the retain/release pairs in `bar`.


Oops, I meant:

  typedef void (^BlockTy)();
  
  BlockTy sb;
  __weak BlockTy wb;
  
  void bar(BlockTy b) {
    wb = b;
    sb = b;
  }
  
  void foo(id a) {
    bar(^{ NSLog(@"foo %@", a); });
  }
  
  int main() {
    auto x = [NSObject new];
    foo(x);
    sb();
    wb();
    return 0;
  }

Is it the same?  Does `b` get retained at the entry to `bar()`?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58514/new/

https://reviews.llvm.org/D58514



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to