<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Cannot jump to switch label when using blocks and ARC"
   href="https://llvm.org/bugs/show_bug.cgi?id=25294">25294</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Cannot jump to switch label when using blocks and ARC
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>warp@iki.fi
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang reports version: Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0

Consider the following code:

//-----------------------------------------------------------
int foo(int i)
{
    NSString* str = [NSString new];
    int(^func)() = nil;
    switch(i)
    {
      case 0: func = ^{ return (int)str.length; }; break;
      case 1: func = ^{ return (int)str.length; }; break;
    }
    return func();
}
//-----------------------------------------------------------

When compiling with ARC enabled, it gives the following error:

test.m:10:7: error: cannot jump from switch statement to this case label
      case 1: func = ^{ return (int)str.length; }; break;
      ^
test.m:5:15: note: jump enters lifetime of block which strongly captures a
variable
    NSString* str = [NSString new];

Note that these functions do not cause an error:

//-----------------------------------------------------------
int foo2(int i)
{
    int value = i * 2;
    int(^func)() = nil;
    switch(i)
    {
      case 0: func = ^{ return value * 2; }; break;
      case 1: func = ^{ return value * 3; }; break;
    }
    return func();
}

int(^foo3(int i))()
{
    NSString* str = [NSString new];
    switch(i)
    {
      case 0: return ^{ return (int)str.length; };
      case 1: return ^{ return (int)str.length; };
    }
    return 0;
}
//-----------------------------------------------------------</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>