site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 03.09.2009, at 23:42, Terry Lambert wrote: Actually the following code fails to compile with the same message: typedef void (^dispatch_block_t)(); class Foo { void Bar() { dispatch_block_t b = ^{ int i = 1; }; } }; while the following with an explicit scope for i works: typedef void (^dispatch_block_t)(); class Foo { void Bar() { dispatch_block_t b = ^{ int ::i = 1; }; } }; Any thoughts? Nico _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Sep 3, 2009, at 1:48 PM, Greg Parker wrote: On Sep 3, 2009, at 1:40 PM, Terry Lambert wrote: The C++ standard limits the scope of variables declared like you are declaring 'i' (as a for-init-statement, technically) to the for itself, rather than extending to the end of the enclosing scope. This is a standards related change in behaviour from traditional C++/g++, which, while not permitted by the standard, is how old compilers tended to be implemented, not having an explicit indicator for interior scope ends in their parse tree representation. There's nothing wrong with his `for` scope here; he didn't use `i` at all, much less use it out of scope. A block-local variable in a C ++ method fails the same way with no loop at all: Then perhaps my observation about the compiler option that causes this to happen in C code as well will be helpful in identifying a root cause in the C++ compiler? -- Terry block.cpp: In function ‘void __Bar_block_invoke_1(void*)’: block.cpp:7: error: ‘int Foo::i’ is not a static member of ‘class Foo’ This email sent to site_archiver@lists.apple.com