From: Daniel Dunbar
Date: Tue, 9 Nov 2010 22:45:16 +0000 (+0000)
Subject: Add a compat note about how Clang doesn't zero-initialize __block local variables.
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15952c91671ce2d7a3da9e219d923a104cc432ec;p=clang
Add a compat note about how Clang doesn't zero-initialize __block local variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118641 91177308-0d34-0410-b5e6-96231b3b80d8
---
diff --git a/www/compatibility.html b/www/compatibility.html
index 68fd025929..c25ea8a4aa 100644
--- a/www/compatibility.html
+++ b/www/compatibility.html
@@ -35,6 +35,7 @@
"missing" vector __builtin functions
Lvalue casts
Jumps to within __block variable scope
+ Non-initialization of __block variables
Objective-C compatibility
@@ -222,6 +223,29 @@ uses of the variable, 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.
+
+Non-initialization of __block
+variables
+
+
+In the following example code, the x variable is used before it is
+defined:
+
+int f0() {
+ __block int x;
+ return ^(){ return x; }();
+}
+
+
+By an accident of implementation, GCC and llvm-gcc unintentionally always
+zero initialized __block variables. However, any program which depends
+on this behavior is relying on unspecified compiler behavior. Programs must
+explicitly initialize all local block variables before they are used, as with
+other local variables.
+
+Clang does not zero initialize local block variables, and programs which rely
+on such behavior will most likely break when built with Clang.
+
Objective-C compatibility