This improves the fairly uninformative "Operation not supported" message given when std::thread is used without linking to libpthread.
Now you get: terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted Aborted PR libstdc++/52681 * src/c++11/thread.cc (thread::_M_start_thread): Improve error text when threads are not enabled. Tested x86_64-linux, with exceptions enabled and disabled. Committed to trunk.
commit d79ac9a14880d5f20fd62c72d87c4f3405727350 Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Sun Aug 12 18:57:53 2012 +0000 PR libstdc++/52681 * src/c++11/thread.cc (thread::_M_start_thread): Improve error text when threads are not enabled. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190330 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc index ff034b1..5c10832 100644 --- a/libstdc++-v3/src/c++11/thread.cc +++ b/libstdc++-v3/src/c++11/thread.cc @@ -115,7 +115,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION thread::_M_start_thread(__shared_base_type __b) { if (!__gthread_active_p()) +#if __EXCEPTIONS + throw system_error(make_error_code(errc::operation_not_permitted), + "Enable multithreading to use std::thread"); +#else __throw_system_error(int(errc::operation_not_permitted)); +#endif __b->_M_this_ptr = __b; int __e = __gthread_create(&_M_id._M_thread,