From 5dc823f7efd3535597203495c090bd053f83bfc2 Mon Sep 17 00:00:00 2001
From: Daniel Dunbar
Clang disallows jumps into the scope of a __block variable, similar +to the manner in which both GCC and Clang disallow jumps into the scope of +variables which have user defined constructors (in C++).
+ +Variables marked with __block require special runtime initialization +before they can be used. A jump into the scope of a __block variable +would bypass this initialization and therefore the variable cannot safely be +used.
+ +For example, consider the following code fragment:
+ ++int f0(int c) { + if (c) + goto error; + + __block int x; + x = 1; + return x; + + error: + x = 0; + return x; +} ++ +
GCC accepts this code, but it will crash at runtime along the error path, +because the runtime setup for the storage backing the x variable will +not have been initialized. Clang rejects this code with a hard error:
+ ++t.c:3:5: error: goto into protected scope + goto error; + ^ +t.c:5:15: note: jump bypasses setup of __block variable + __block int x; + ^ ++ +
Some instances of this construct may be safe if the variable is never used +after the jump target, however the protected scope checker does not check the +uses of the varaible, only the scopes in which it is visible. You should rewrite +your code to put the __block variables in a scope which is only visible +where they are used.
+