Blocks bear a superficial resemblance to
GCC's extension of C to support
lexically scoped nested functions. However, GCC's nested functions, unlike blocks, must not be called after the containing scope has exited, as that would result in
undefined behavior. GCC-style nested functions currently use dynamic creation of executable
thunks on most architectures when taking the address of the nested function. On most architectures (including
x86), these thunks are created on the stack, which requires marking the stack executable.
Executable stacks are generally considered to be a potential security hole. Blocks do not require the use of executable thunks, so they do not share this weakness. On the other hand, blocks introduces a completely new type for the pointer, while pointers to nested functions in GCC are regular function pointers and can be used directly with existing code. ==See also==