std::auto_ptr crashes on assignment with VC8.0
#include <memory>
class X
{
public:
double d_;
};
std::auto_ptr<X> px = new X; // shouldn't compile at all
- gcc 3.3.5: doesn't compile - ok
- VC8.0: does compile, but crashes when
pxis accessed or destructed. Reason: During the assignmentnew Xis implicitly converted to an auto_ptr_ref which accecpts avoid*in its constructor. Butstd::auto_ptr_refexpects astd::auto_ptr<X>**instead of aX*. So, treatingX*like it was astd::auto_ptr<X>**is unlikely to yield pretty results.
There is a related discussion on comp.lang.c++. There is also a related discussion in a MSDN-forum but it's more noise than signal.