https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58909

--- Comment #22 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In that case it finds the no-op symbol in libc.so.6 and doesn't crash.

$ g++ cv.C   -g -Wl,--trace-symbol=pthread_cond_destroy 
/usr/bin/ld: /lib64/libc.so.6: definition of pthread_cond_destroy


This fixes the static linking case:

--- a/libstdc++-v3/src/c++11/condition_variable.cc
+++ b/libstdc++-v3/src/c++11/condition_variable.cc
@@ -31,9 +31,19 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION

-  condition_variable::condition_variable() noexcept = default;
+  condition_variable::condition_variable() noexcept
+  {
+#if defined __GLIBC__ && ! defined _GLIBCXX_SHARED
+    asm("extern pthread_cond_init");
+#endif
+  }

-  condition_variable::~condition_variable() noexcept = default;
+  condition_variable::~condition_variable() noexcept
+  {
+#if defined __GLIBC__ && ! defined _GLIBCXX_SHARED
+    asm("extern pthread_cond_destroy");
+#endif
+  }

   void
   condition_variable::wait(unique_lock<mutex>& __lock) noexcept

Reply via email to