[Bug c++/12883] New: array of auto_ptr's: destructors not called (under certain circumstances)
mxm01 at comm2000 dot it
gcc-bugzilla@gcc.gnu.org
Mon Nov 3 11:52:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12883
Summary: array of auto_ptr's: destructors not called (under
certain circumstances)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mxm01 at comm2000 dot it
CC: gcc-bugs at gcc dot gnu dot org
#include <iostream>
#include <memory>
class A { public: ~A() {std::cout<<"~"<< std::endl; } };
int main()
{
std::auto_ptr<A> array[] = { std::auto_ptr<A>(new A),
std::auto_ptr<A>(new A) };
}
// Apparently, A's destructors do not get called.
// If the array size is specified (" array[2] = "), though,
// destructors get called.
// Also, if an additional 'auto_ptr<A>' is instantiated just
// before 'array', destructors get called.
// (Tried with gcc 2.91,2.95,3.0,3.2)
More information about the Gcc-bugs
mailing list