<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 30, 2008, at 9:44 PM, Zhongxing Xu 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; ">On Fri, Oct 31, 2008 at 12:27 PM, Ted Kremenek<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; "><div class="Ih2E3d"><br>On Oct 30, 2008, at 7:56 PM, Zhongxing Xu wrote:<br><br><blockquote class="gmail_quote" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; ">Hi Ted,<br><br>Would visiting the InitList from right to left lead to some bugs? For example:<br><br>int x = 3;<br>int a[3] = {1, x = 1, 2*x+3};<br><br>At last a should be { 1, 1, 5 }. But visit from right to left results { 1, 1, 9 }<br></blockquote><br></div>I don't think the order of evaluation is defined (we should consult the standard).  If there is an explicit control-flow dependency between the subexpressions, we should put that explicitly in the CFG.  In that case visiting the subexpressions from right-to-left or left-to-right won't matter (as the expressions will have already been evaluated).</blockquote><div><br>Agree.</div></span></blockquote><br></div><div>Another thing I thought of is cases like the following:</div><div><br></div><div>int a[3] = { x = (y = 2 * x), (x = 2 * y) ? 4 : 5, x };</div><div><br></div><div>Here there is a bunch of control-flow, but because of the ? operator the expression "(x = 2 * y) ? 4" will always be evaluated first (since it is hoisted in the CFG as a block-level expression), even if we did left-to-right visitation of the the subexpressions of the InitListExpr.  Thus the only way to ensure a fixed order of evaluation is to put it in the CFG (i.e., we couldn't do it in GRExprEngine even if we wanted to).</div></body></html>