[cfe-dev] switch over constant results in strange constructor/destructor ordering

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Sat Sep 17 09:31:02 PDT 2016


I don't know if we're planning on another patch release for 3.8, but I've
already asked our patch release manager to put this into 3.9.1.

On 17 Sep 2016 8:29 am, "Fletcher, John P" <j.p.fletcher at aston.ac.uk> wrote:

> Richard
>
> I see the same faulty output with Clang 3.6.0 and 3.8.0.
>
> Is there anything which should be done about this pending an updated
> release?
>
> Thanks
>
> John
>
> ------------------------------
> *From:* cfe-dev [cfe-dev-bounces at lists.llvm.org] on behalf of Richard
> Smith via cfe-dev [cfe-dev at lists.llvm.org]
> *Sent:* 17 September 2016 00:39
> *To:* Andrew Johnson
> *Cc:* Clang Dev
> *Subject:* Re: [cfe-dev] switch over constant results in strange
> constructor/destructor ordering
>
> Thanks for letting us know, fixed in r281797.
>
> On Fri, Sep 16, 2016 at 2:13 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>
>> Wow, yes, that's a (pretty scary) wrong-code bug. Working on it...
>>
>> On Fri, Sep 16, 2016 at 6:47 AM, Andrew Johnson via cfe-dev <
>> cfe-dev at lists.llvm.org> wrote:
>>
>>> Hello,
>>>
>>> I'm seeing an unexpected construction/destruction order in the program
>>> below with clang 3.9.0. Is this considered a bug? Thank you.
>>>
>>> clang asm - https://godbolt.org/g/uGlpFa
>>> gcc asm - https://godbolt.org/g/WDgcZP
>>>
>>> printf Output from clang (Unexpected):
>>> obj entered 0
>>> obj entered 1
>>> obj entered 2
>>> obj exited 2
>>> obj exited 1
>>> obj exited 0
>>>
>>> printf Output from gcc (Expected):
>>> obj entered 0
>>> obj exited 0
>>> obj entered 1
>>> obj exited 1
>>> obj entered 2
>>> obj exited 2
>>>
>>>
>>> Program:
>>>
>>> #include <stdint.h>
>>> #include <stdio.h>
>>>
>>> class SomeClass
>>> {
>>> uint32_t k;
>>> public:
>>> SomeClass(uint32_t x)
>>>         { k = x; printf("obj entered %d\n", k); }
>>> ~SomeClass()
>>>         { printf("obj exited %d\n", k); }
>>>
>>> };
>>>
>>> int main()
>>> {
>>> uint32_t ii = 0;
>>>
>>> switch(1)
>>> {
>>> default:
>>> {
>>>
>>> {
>>> SomeClass someClass(ii++);
>>> }
>>>
>>> {
>>> SomeClass someClass2(ii++);
>>> }
>>>
>>> {
>>> SomeClass someClass3(ii++);
>>> }
>>> }
>>> }
>>> }
>>>
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160917/b63633e2/attachment.html>


More information about the cfe-dev mailing list