]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* include/std/mutex (call_once): Remove parentheses to fix error in
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Jun 2013 23:54:07 +0000 (23:54 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Jun 2013 23:54:07 +0000 (23:54 +0000)
c++1y and gnu++1y mode.
* testsuite/30_threads/mutex/try_lock/2.cc: Call try_lock() in new
thread to avoid undefined behaviour.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199875 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/mutex
libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc

index 8ca5e1ac814a792ba65d47e9cd49e800b93ffa35..5934f9bbe0addfe3618c9e8f2dfee2c37bd8bac8 100644 (file)
@@ -1,3 +1,10 @@
+2013-06-09  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       * include/std/mutex (call_once): Remove parentheses to fix error in
+       c++1y and gnu++1y mode.
+       * testsuite/30_threads/mutex/try_lock/2.cc: Call try_lock() in new
+       thread to avoid undefined behaviour.
+
 2013-06-08  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        Simplify and clean up library literals.
index 3c666c19e5028bf465785f1fae317f9c23a2ae8f..cdd05a37cbeeab0250e70a3dd7d2275aad7ca248 100644 (file)
@@ -783,7 +783,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __set_once_functor_lock_ptr(&__functor_lock);
 #endif
 
-      int __e = __gthread_once(&(__once._M_once), &__once_proxy);
+      int __e = __gthread_once(&__once._M_once, &__once_proxy);
 
 #ifndef _GLIBCXX_HAVE_TLS
       if (__functor_lock)
index bb3fcd412e4e46d41501febbe492e06c52b0371e..f2a67231cdadba98b909bf0343613d5d4fdd392d 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include <mutex>
+#include <thread>
 #include <system_error>
 #include <testsuite_hooks.h>
 
@@ -38,15 +39,18 @@ int main()
       m.lock();
       bool b;
 
-      try
-       {
-         b = m.try_lock();
-         VERIFY( !b );
-       }
-      catch (const std::system_error& e)
-       {
-         VERIFY( false );
-       }
+      std::thread t([&] {
+        try
+          {
+            b = m.try_lock();
+          }
+        catch (const std::system_error& e)
+          {
+            VERIFY( false );
+          }
+      });
+      t.join();
+      VERIFY( !b );
 
       m.unlock();
     }