https://llvm.org/bugs/show_bug.cgi?id=25294
Bug ID: 25294 Summary: Cannot jump to switch label when using blocks and ARC Product: clang Version: unspecified Hardware: Macintosh OS: MacOS X Status: NEW Severity: normal Priority: P Component: -New Bugs Assignee: unassignedclangb...@nondot.org Reporter: w...@iki.fi CC: llvm-bugs@lists.llvm.org Classification: Unclassified 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; } //----------------------------------------------------------- -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs