[llvm-bugs] [Bug 31386] New: All temporaries aren't destroyed in InitListExpr filler

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 15 00:56:12 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=31386

            Bug ID: 31386
           Summary: All temporaries aren't destroyed in InitListExpr
                    filler
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stephane.zimmermann at trust-in-soft.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17757
  --> https://llvm.org/bugs/attachment.cgi?id=17757&action=edit
Test case

The file:

#include <cstdio>

class Foo {
    static int counter;

public:
    int objectID;
    Foo() { objectID = counter++; }
    Foo(const Foo&) { objectID = counter++; }
    ~Foo() { printf("~Foo() : %d\n", objectID); }
};

int Foo::counter = 0;

struct Bar {
    Bar(Foo f = Foo()) {}
};

int main(void) {
    Bar b[13] = { Foo(), Foo() };
    return 0;
}

compiled with Clang has as output:

$ clang++ test.cpp && ./a.out 
~Foo() : 12
~Foo() : 1
~Foo() : 0

which shows that only the last temporary used in the creation of b is
destroyed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161215/a2539026/attachment.html>


More information about the llvm-bugs mailing list