It is an error to assign or copy a const auto_ptr. g++ should refuse to compile the following code:
"bug.cpp": #include <memory> int main() { class A { const std::auto_ptr<int> a; }; A a; } Compiled with: g++ bug.cpp This code compiles, incorrectly, on the following version of gcc: Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=i386-redhat-linux Thread model: posix gcc version 4.1.2 20070502 (Red Hat 4.1.2-12) -- Summary: Default copy constructor copies const auto_ptr members Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jeidsath at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34180