I am getting abort exception in simple VC++ program when main method completes.
Here is my sample test program.
#include \"stdafx.h\"
#include
This is documented in std::thread
's destructor: if a thread is destroyed while it is joinable, std::terminate
is called.
Quote from the C++11 standard draft n3290 (§30.3.1.3 thread destructor):
If
joinable()
thenterminate()
, otherwise no effects. [ Note: Either implicitly detaching or joining a joinable() thread in its destructor could result in difficult to debug correctness (for detach) or performance (for join) bugs encountered only when an exception is raised. Thus the programmer must ensure that the destructor is never executed while the thread is still joinable. — end note ]
You must either join the thread, or detach it. Joining seems like the right option in your case.