N
Noah Roberts
#include <iostream>
#include <memory>
struct T {};
std::auto_ptr<T> f() { return new T; }
int main()
{
std::auto_ptr<T> at = f();
std::cout << "test\n";
std::cin.get();
}
The above code should compile and work fine, no? I should not be
getting a crash due to doubly deleted memory segments...right?
Because in MSVC++ 8.0 the above code compiles but crashes. I find it
hard to believe that MSVC could have a library that's so trivially
hosed, but by my understanding of the docs on std::auto_ptr...the above
code should run without crashing.
#include <memory>
struct T {};
std::auto_ptr<T> f() { return new T; }
int main()
{
std::auto_ptr<T> at = f();
std::cout << "test\n";
std::cin.get();
}
The above code should compile and work fine, no? I should not be
getting a crash due to doubly deleted memory segments...right?
Because in MSVC++ 8.0 the above code compiles but crashes. I find it
hard to believe that MSVC could have a library that's so trivially
hosed, but by my understanding of the docs on std::auto_ptr...the above
code should run without crashing.