This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12883] New: array of auto_ptr's: destructors not called (under certain circumstances)
- From: "mxm01 at comm2000 dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Nov 2003 11:52:21 -0000
- Subject: [Bug c++/12883] New: array of auto_ptr's: destructors not called (under certain circumstances)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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)