Commit bd24ec2d by Jonathan Wakely Committed by Jonathan Wakely

mutex (call_once): Remove parentheses to fix error in c++1y and gnu++1y mode.

	* 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.

From-SVN: r199875
parent 0d008882
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> 2013-06-08 Ed Smith-Rowland <3dw4rd@verizon.net>
Simplify and clean up library literals. Simplify and clean up library literals.
......
...@@ -783,7 +783,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -783,7 +783,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__set_once_functor_lock_ptr(&__functor_lock); __set_once_functor_lock_ptr(&__functor_lock);
#endif #endif
int __e = __gthread_once(&(__once._M_once), &__once_proxy); int __e = __gthread_once(&__once._M_once, &__once_proxy);
#ifndef _GLIBCXX_HAVE_TLS #ifndef _GLIBCXX_HAVE_TLS
if (__functor_lock) if (__functor_lock)
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <mutex> #include <mutex>
#include <thread>
#include <system_error> #include <system_error>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
...@@ -38,15 +39,18 @@ int main() ...@@ -38,15 +39,18 @@ int main()
m.lock(); m.lock();
bool b; bool b;
try std::thread t([&] {
{ try
b = m.try_lock(); {
VERIFY( !b ); b = m.try_lock();
} }
catch (const std::system_error& e) catch (const std::system_error& e)
{ {
VERIFY( false ); VERIFY( false );
} }
});
t.join();
VERIFY( !b );
m.unlock(); m.unlock();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment