<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 16, 2008, at 2:21 PM, Cédric Venet wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; ">Mainly project change but also a few missing std include header and one<br>compiler bug (or not, I don't know what the standard say):<br><br>for (GRExprEngine::null_iterator I=CheckerState->null_begin(),<br>        E=CheckerState->null_end(); I!=E; ++I) {<br><br>     const PostStmt& L = cast<PostStmt>((*I)->getLocation());<br>     Expr* E = cast<Expr>(L.getStmt());<br><br>     Diag.Report(FullSourceLoc(E->getExprLoc(), Ctx.getSourceManager()),<br>                 diag::chkr_null_deref_after_check);<br>   }<br><br>Not Expr* E who redefine E from the for initialization. Is it the same<br>scope? The strangest thing was that MSVC didn't complain about redefinition<br>but seemed to ignore the Expr* E; definition and was thinking E was a<br>null_iterator. Took me some time to understand the problem.</span></blockquote></div><br><div>I'm not as adroit in interpreting the C99 standard as others, but I believe that one could interpret the prose of the standard to say that the loop condition has a different scope than the loop body, or at least variables declared in within the parentheses of "for(...)" are visible to the other expressions in the for(...) (variables declared in the loop body are not visible to subexpression representing the loop condition or the optional "increment" expression) (6.8.5.3):</div><div><br class="webkit-block-placeholder"></div><div><div><i>The statement </i></div><div><i> </i></div><div><i>  for ( clause-1 ;expression-2 ;expression-3 ) statement</i></div> <div><i><br class="webkit-block-placeholder"></i></div></div><i>behaves as follows: The expression "expression-2" is the controlling expression that is  evaluated before each execution of the loop body. The expression "expression-3" is evaluated as a void expression after each execution of the loop body. If clause-1is a declaration, </i><b><i>the scope of any variables it declares is the remainder of the declaration and  the entire loop, including the other two expressions</i></b><i>; it is reached in the order of execution before the first evaluation of the controlling expression.</i></body></html>