[LLVMbugs] [Bug 12286] New: clang fails to destroy return value when a destructor throws
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Mar 16 15:41:51 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12286
Bug #: 12286
Summary: clang fails to destroy return value when a destructor
throws
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: rjmccall at apple.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
If an exception is thrown after a non-POD return value is successfully
constructed in the return slot but before the returning function terminates,
the value in the return slot is not destroyed. This can be clearly seen in the
following test case. The really easy solution would be to push an inactive
destructor cleanup in the prologue and activate it whenever evaluation
completes for a return value, but that wouldn't be the correct ordering of
destruction as specified in [except.ctor]p1. Needs more thought.
#include <stdio.h>
struct A {
A() { printf("creating A at %p\n", this); }
A(const A &a) { printf("copying A at %p into %p\n", &a, this); }
~A() { printf("destroying A at %p\n", this); }
};
struct B {
B() { printf("entering B\n"); }
~B() { printf("exiting B, throwing!\n"); throw 0; }
};
A test() {
B b;
return A();
}
int main() {
try {
printf("running\n");
A a = test();
} catch (int i) {
printf("caught\n");
}
}
--
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