This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9993: [3.2/3.3/3.4 regression] destructor not called for local object created within and returned from infinite loop
- From: bangerth at dealii dot org
- To: Jon_Udell at mentor dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 15 Mar 2003 05:34:26 -0000
- Subject: Re: c++/9993: [3.2/3.3/3.4 regression] destructor not called for local object created within and returned from infinite loop
- Reply-to: bangerth at dealii dot org, Jon_Udell at mentor dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Old Synopsis: destructor not called for local object created within and returned from infinite loop
New Synopsis: [3.2/3.3/3.4 regression] destructor not called for local object created within and returned from infinite loop
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Sat Mar 15 05:34:26 2003
State-Changed-Why:
Indeed:
---------------------------
extern "C" void printf (const char *, ...);
#define PRINT printf ("%s\n", __PRETTY_FUNCTION__)
struct Object {
Object() { PRINT; }
Object(const Object&) { PRINT; }
void operator=(const Object&) { PRINT; }
~Object() { PRINT; }
};
Object function() {
int i = 0;
do {
Object b;
if (i++ == 2)
return b;
} while (1);
}
int main() {
function();
}
-----------------------------
This is the output with 3.2/3.3/3.4:
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc
g/x> ./a.out
Object::Object()
Object::Object()
Object::Object()
Object::~Object()
Ups. Not right. 2.95 generates
g/x> ./a.out
Object::Object()
Object::~Object()
Object::Object()
Object::~Object()
Object::Object()
Object::Object(const Object &)
Object::~Object()
Object::~Object()
So this is a regression.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9993