[LLVMbugs] [Bug 13233] New: Destructors not called for fields of a temporary created with initializer list

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 28 17:04:16 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13233

             Bug #: 13233
           Summary: Destructors not called for fields of a temporary
                    created with initializer list
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: davorin.ucakar at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8788
  --> http://llvm.org/bugs/attachment.cgi?id=8788
example

In the following code, destructor for Foo f field in temporary Bar instance is
not called.

struct Foo {
  ~Foo() {}
};

struct Bar {
  Foo f;
};

void set( const Bar& b_ ) {
  Bar b = b_;
}

int main() {
  set( { Foo() } ); // destructor for Foo is not called
  return 0;
}

The attached code, that includes a more detailed example, outputs:
Foo(temp)
Foo( const Foo& )
~Foo()

instead of (compiled with GCC 4.7):
Foo(temp)
Foo( const Foo& )
~Foo()
~Foo(temp)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list