This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12883] New: array of auto_ptr's: destructors not called (under certain circumstances)


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]