According to the standard specification:
1 … names declared in the for-init-statement are in the same declarative-region as those declared in the condition
3 If the for-init-statement is a declaration, the scope of the name(s) declared extends to the end of the for-statement. [§6.5.3]
and
4
Names declared in the for-init-statement, the for-range-declaration, and in the condition of if, while, for, and switch statements are local to the if, while, for, or switch statement (including the controlled statement), and shall not be redeclared in a subsequent condition of that statement nor in the outermost block (or, for the if statement, any of the outermost blocks) of the controlled statement [§3.3.3]
The behavior of MSVC++2010 is not standard and it’s a bug.