This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52320] missing destructor call after thrown exception in initializer
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Feb 2012 08:26:30 +0000
- Subject: [Bug c++/52320] missing destructor call after thrown exception in initializer
- Auto-submitted: auto-generated
- References: <bug-52320-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52320
Daniel KrÃgler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2012-02-21 08:26:30 UTC ---
Confirmed for 4.7.0 20120218 (experimental).
Reduced example with added information:
//----
#include <iostream>
#define FUNCTION_NAME __PRETTY_FUNCTION__
#define TRACE_FUNCTION(I) { std::cout << this << "->" << FUNCTION_NAME << "; i
= " << I << std::endl; }
struct A {
int i;
A(int i) : i(i) { TRACE_FUNCTION(i); }
A(const A& rhs) : i(rhs.i) { TRACE_FUNCTION(i); }
A &operator=(const A& rhs) { i = rhs.i; TRACE_FUNCTION(i); return *this; }
~A() { TRACE_FUNCTION(i); }
};
struct Y {
A e1[2];
};
int main() {
try {
Y y1[1] = { {{1, (throw 0, 2)} } };
} catch (int) {
}
}
//----
Observed output is:
0x22fd60->A::A(int); i = 1
It does not happen when the local array y1 is replaced by a non-array Y.