Dear all<div><br></div><div>I have found out that in clang conditional temporaries are destroyed not at the end of the full expression as in gcc but apparently at the end of the conditional branch.</div><div><br></div><div>

For example, consider the program below:</div><div><br></div><div><div>#include <stdio.h></div><div><br></div><div>struct S</div><div>{</div><div>    int i;</div><div>    S() { puts("S"); }</div><div>    ~S() { puts("~S"); }</div>

<div>};</div><div><br></div><div>void f(int) { puts("f"); }</div><div><br></div><div>volatile bool b = true;</div><div><br></div><div>int main()</div><div>{</div><div>    f(b ? S().i : 0);</div><div>}</div><div>

<br></div><div>If it is compiled with gcc and run the output is: </div><div>S</div><div>f</div><div>~S</div><div><br></div><div>With clang the output is:</div><div>S</div><div>~S</div><div>f</div><div><br></div><div>The same applies to && and || operators. Is this intended or needs to be fixed in clang?</div>

<div>In the latter case and if nobody is already working on it I can try fixing it.</div><div><br></div><div>Best regards,</div><div>Victor</div><div><br></div></div>