because c++11 9.8/1 states
Declarations in a local class shall not odr-use (3.2) a variable with automatic storage duration from an enclosing scope.
and 3.2/2 states
An expression is potentially evaluated unless it is an unevaluated operand (Clause 5) or a subexpression thereof. A variable whose name appears as a potentially-evaluated expression is odr-used unless it is an object that satisfies the requirements for appearing in a constant expression (5.19) and the lvalue-to-rvalue conversion (4.1) is immediately applied.
主楼程序中 int arr[size]; 中对于 size 的使用是 constant expression,并且 lvalue-to-rvalue conversion 立即生效,所以不属于 odr-use,因此符合标准。
而 cout << size << endl; 中的 size 不是 constant expression,所以是 odr-used,违反了 9.8/1,导致编译错误。
size 改成 static 就可以,因为 9.8/1 只规范 automatic storage duration,其实把它变成全局变量也可以绕过 9.8/1.