---------- code ---------------- #include <cstdio> #include <thread>
using namespace std; void f() { fputs("f()\n", stderr); } int main() { fputs("before new thread\n", stderr); thread t(f); fputs("after new thread\n", stderr); t.join(); fputs("after join\n", stderr); return 0; } ---------- system information ---------------- uname -a: Linux nuty 2.6.33-rc2-zen1-zen-nuty-07221-g526ecd7 #4 ZEN PREEMPT Sun Jan 10 23:33:42 CET 2010 i686 Intel(R) Pentium(R) M processor 1.40GHz GenuineIntel GNU/Linux gcc --version: gcc (GCC) 4.4.2 20091208 (prerelease) Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ---------- complier arguments ---------------- $ g++ -std=c++0x -pthread thread.cc -o thread ---------- output ---------------- before new thread after new thread pure virtual method called terminate called without an active exception ---------- gdb run ---------------- (gdb) r Starting program: /tmp/thread [Thread debugging using libthread_db enabled] before new thread [New Thread 0xb7d30b70 (LWP 5676)] after new thread pure virtual method called terminate called without an active exception Program received signal SIGABRT, Aborted. [Switching to Thread 0xb7d30b70 (LWP 5676)] 0xb7fe1424 in __kernel_vsyscall () (gdb) bt #0 0xb7fe1424 in __kernel_vsyscall () #1 0xb7d5c571 in raise () from /lib/libc.so.6 #2 0xb7d5dd72 in abort () from /lib/libc.so.6 #3 0xb7f9352f in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6 #4 0xb7f90eb5 in __cxxabiv1::__terminate(void (*)()) () from /usr/lib/libstdc++.so.6 #5 0xb7f90ef2 in std::terminate() () from /usr/lib/libstdc++.so.6 #6 0xb7f92155 in __cxa_pure_virtual () from /usr/lib/libstdc++.so.6 #7 0xb7f89c16 in execute_native_thread_routine () from /usr/lib/libstdc++.so.6 #8 0xb7e7f8ac in start_thread () from /lib/libpthread.so.0 #9 0xb7e0001e in clone () from /lib/libc.so.6 (gdb) info threads * 2 Thread 0xb7d30b70 (LWP 5676) 0xb7fe1424 in __kernel_vsyscall () 1 Thread 0xb7d316d0 (LWP 5673) 0xb7fe1424 in __kernel_vsyscall () (gdb) thread 1 [Switching to thread 1 (Thread 0xb7d316d0 (LWP 5673))]#0 0xb7fe1424 in __kernel_vsyscall () (gdb) bt #0 0xb7fe1424 in __kernel_vsyscall () #1 0xb7e80a3d in pthread_join () from /lib/libpthread.so.0 #2 0xb7f89b22 in std::thread::join() () from /usr/lib/libstdc++.so.6 #3 0x08048b30 in main () at thread.cc:16 (gdb) -- Summary: trivial use of std::thread fails with "pure virtual method called" Product: gcc Version: 4.4.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: phil at nwl dot cc http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42734