<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - __NSStackBlock__ cant't be copy to __NSMallocBlock__ in arc"
   href="https://bugs.llvm.org/show_bug.cgi?id=46399">46399</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__NSStackBlock__ cant't be copy to __NSMallocBlock__ in arc
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sunbohong@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The follow code will be crash in iOS.

-(NSArray*)getBlockArray
{
  int num = 916;
  return [NSArray arrayWithObjects:
          ^{ NSLog(@"this is block 0:%i", num); },
          ^{ NSLog(@"this is block 1:%i", num); },
          ^{ NSLog(@"this is block 2:%i", num); },
          nil];
}

- (void)forTest
{
  int a = 10;
  int b = 20;
}

- (void)test
{
  NSArray*  blockArr = [self getBlockArray];
  [self forTest];

  void (^blockObject)(void);
  for(blockObject in blockArr){
    blockObject();
}

===================
And the follow code will print blocks with different type in macOS.

void testBlockArray() {
  int val = 10;
  NSArray *arr = [NSArray arrayWithObjects:^(){NSLog(@"blk0:%d",
val);},^(){NSLog(@"blk1:%d", val);}, nil];
  NSLog(@"%@", arr);

}

(
    "<__NSMallocBlock__: 0x600003bb6e80>",
    "<__NSStackBlock__: 0x7ffedfdf7c10>"
)


==================

I try to fix this crash with
<a href="https://github.com/sunbohong/llvm-project/commit/7132d1ee82431ee182775cc65d5de1091cb78cde">https://github.com/sunbohong/llvm-project/commit/7132d1ee82431ee182775cc65d5de1091cb78cde</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>