C++98의 정의는 다음과 같습니다.
The for statement
for ( for-init-statement condition_opt ; expression_opt ) statement
is equivalent to
{
for-init-statement
while ( condition ) {
statement
expression;
}
}
except that name declared in the for-init-statement are in the same
declarative-region as those declared in the condition, and except that a
continue in statement (not enclosed in another iteration statement) will
excute expression before re-evaluating condition.
C99의 정의는 다음과 같습니다.
If clause-1 is a declaration, the scope of any variables it declares is
the remainder of the declaration and the entire loop, including the other
two expressions;
결론: 표준을 준수하는 요즘 컴파일러를 사용한다면 loop invariant 정의는
loop statement를 사용할 때 하시기를 권장하고 그것이 표준에도 맞습니다.
두 표준의 어버이격인 C90은 슬슬 잊고 살아도 될 때가 된 것 아닌가 합니다.
--
TeX and EMACS live together in perfect harmony.