<div dir="ltr">Wow, yes, that's a (pretty scary) wrong-code bug. Working on it...<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 16, 2016 at 6:47 AM, Andrew Johnson via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><font face="monospace, monospace">Hello,</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I'm seeing an unexpected construction/destruction order in the program below with clang 3.9.0. Is this considered a bug? </font><span style="font-family:monospace,monospace">Thank you.</span></div><font face="monospace, monospace"><div><br></div><div><div>clang asm - <a href="https://godbolt.org/g/uGlpFa" target="_blank">https://godbolt.org/g/uGlpFa</a><br></div>gcc asm - <a href="https://godbolt.org/g/WDgcZP" target="_blank">https://godbolt.org/g/WDgcZP</a><br></div><div><br></div></font><div><font face="monospace, monospace">printf Output from clang (Unexpected):</font></div><div><div><font face="monospace, monospace">obj entered 0</font></div><div><font face="monospace, monospace">obj entered 1</font></div><div><font face="monospace, monospace">obj entered 2</font></div><div><font face="monospace, monospace">obj exited 2</font></div><div><font face="monospace, monospace">obj exited 1</font></div><div><font face="monospace, monospace">obj exited 0</font></div></div><div><br></div><div><span style="font-family:monospace,monospace">printf Output from gcc (Expected):</span></div><div><div><font face="monospace, monospace">obj entered 0</font></div><div><font face="monospace, monospace">obj exited 0</font></div><div><font face="monospace, monospace">obj entered 1</font></div><div><font face="monospace, monospace">obj exited 1</font></div><div><font face="monospace, monospace">obj entered 2</font></div><div><font face="monospace, monospace">obj exited 2</font></div><div style="font-family:monospace,monospace"><br></div></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">Program:</div><div style="font-family:monospace,monospace"><br></div><div><span style="font-family:monospace,monospace">#include <stdint.h></span><br></div><div><div><div><font face="monospace, monospace">#include <stdio.h></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">class SomeClass</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>uint32_t k;</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>public:</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>SomeClass(uint32_t x)</font></div><div><font face="monospace, monospace"> { k = x; printf("obj entered %d\n", k); }</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>~SomeClass()</font></div><div><font face="monospace, monospace"> { printf("obj exited %d\n", k); }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">};</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">int main()</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>uint32_t ii = 0;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>switch(1)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>{</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>default:</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>{</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>{</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>SomeClass someClass(ii++);</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>{</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>SomeClass someClass2(ii++);</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>{</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>SomeClass someClass3(ii++);</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>}</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>}</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>}</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div></div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>