------- Comment #15 from bkoz at gcc dot gnu dot org 2006-10-06 09:48 ------- // try this simpler code.
#include <stdexcept> #include <ext/concurrence.h> namespace { __gnu_cxx::__mutex test_mutex; unsigned int i; } // anonymous namespace void* add(void*) { __gnu_cxx::__scoped_lock sentry(test_mutex); { ++i; // break here } return 0; } void check_thread_create(int ret) { if (ret != 0) { char buf[10]; sprintf(buf, "%u", ret); std::string error("pthread_create failed: "); error += buf; error += strerror(ret); throw std::runtime_error(error); } } int main() { pthread_t id1; pthread_t id2; check_thread_create(pthread_create(&id1, NULL, add, 0)); check_thread_create(pthread_create(&id2, NULL, add, 0)); pthread_join(id1, NULL); pthread_join(id2, NULL); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29118