[LLVMbugs] [Bug 14514] New: Array of class type didn't call destructor automatically after a throw.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 5 01:27:03 PST 2012


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

             Bug #: 14514
           Summary: Array of class type didn't call destructor
                    automatically after a throw.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: wenhan.gu at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Hi all,

The array "A a[1];" didn't call destructor automatically.
This following code explains itself.

I think maybe this is an exception handling bug on array type?
Thanks!

  1 #include <iostream>
  2
  3 struct A {
  4   A() {
  5     std::cerr << "Constructor\n";
  6   }
  7   ~A() {
  8     std::cerr << "Destructor\n";    // Error: Didn't show this.
  9   }
 10 };
 11
 12 struct B {
 13   A a[1];    // If I use "A a;", everything works!
 14
 15   B() {
 16     throw 0;
 17   }
 18 };
 19
 20 int main() {
 21   try {
 22     B b;
 23   } catch (...) {
 24   }
 25   return 0;
 26 }

-- 
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