<div dir="ltr"><span style="font-size:12.8000001907349px">Hi All,</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I am analyzing the following code:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>struct S1 {</div><div><span style="white-space:pre-wrap">        </span>S1() {}</div><div><span style="white-space:pre-wrap">  </span>S1(int x, int y, int z) : a(x), b(y), c(z) {}</div><div><span style="white-space:pre-wrap">    </span>int a;</div><div><span style="white-space:pre-wrap">   </span>int b;</div><div><span style="white-space:pre-wrap">   </span>int c;</div><div>};</div><div><br></div><div>void foo() {</div><div><span style="white-space:pre-wrap">      </span>S1 s2;</div><div><span style="white-space:pre-wrap">   </span>S1 s1(3, 0, 4);</div><div><span style="white-space:pre-wrap">  </span>s2 = s1;</div><div>}</div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">with three callbacks: checkPostStmt, checkPreCall, and checkEndFunction. I would expect the general order of analysis to go something like this:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">PreCall(S1 default constructor)</div><div style="font-size:12.8000001907349px">EndFunction(S1 default constructor)</div><div style="font-size:12.8000001907349px">PreCall(S1 constructor)</div><div style="font-size:12.8000001907349px">Evaluate(S1 constructor)</div><div style="font-size:12.8000001907349px">EndFunction(S1 constructor)</div><div style="font-size:12.8000001907349px">PreCall(S1 copy assignment)</div><div style="font-size:12.8000001907349px">Evaluate(S1 copy assignment)</div><div style="font-size:12.8000001907349px">EndFunction(S1 copy assignment)</div><div style="font-size:12.8000001907349px">EndFunction(foo)</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">where Evaluate() is shorthand for a series of PostStmt's. If I write out an explicit copy assignment operator:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>S1 operator=(const S1 &s) {</div><div>        a = s.a; b = s.b; c = s.c;</div><div>}</div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">then the analysis runs in the expected sequence. But when the copy assignment operator is left implicit, I observe the following sequence:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>PreCall(S1 default constructor)</div><div>EndFunction(S1 default constructor)</div><div>PreCall(S1 constructor)</div><div>Evaluate(S1 constructor)</div><div>EndFunction(S1 constructor)</div><div>PreCall(S1 copy assignment)</div><div>EndFunction(foo)</div></div><div style="font-size:12.8000001907349px">Evaluate(S1 copy assignment)</div><div style="font-size:12.8000001907349px">EndFunction(S1 copy assignment)</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">So the implicit copy assignment operator is actually being evaluated AFTER foo() terminates. This in turn throws off my analyses. </div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">~Scott Constable</div></div>