c++/9993: [3.2/3.3/3.4 regression] destructor not called for local object created within and returned from infinite loop
bangerth@dealii.org
bangerth@dealii.org
Sat Mar 15 07:56:00 GMT 2003
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
More information about the Gcc-bugs
mailing list