[Bug c++/52320] missing destructor call after thrown exception in initializer
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Tue Feb 21 08:38:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list