Scoped capabilities need to be annotated as such, otherwise the thread
safety analysis won't work as intended.
Fixes PR39234.
Differential D53049
Annotate scoped_lock as with scoped_lockable attribute Authored by aaronpuchert on Oct 9 2018, 3:35 PM.
Details Scoped capabilities need to be annotated as such, otherwise the thread Fixes PR39234.
Diff Detail
Event Timeline
Comment Actions Thanks a lot for taking a look so quickly!
Comment Actions Hmm, this seems to be causing buildbot failures, could you take a look? Eg., http://lab.llvm.org:8080/green/job/libcxx_master_cmake/5459/consoleFull /Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp:28:8: error: no member named 'scoped_lock' in namespace 'std'
std::scoped_lock<std::mutex> lock(m);
~~~~~^
/Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp:28:30: error: expected '(' for function-style cast or type construction
std::scoped_lock<std::mutex> lock(m);
~~~~~~~~~~^
/Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp:28:32: error: no matching function for call to 'lock'
std::scoped_lock<std::mutex> lock(m);
^~~~
/Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/include/mutex:372:1: note: candidate function template not viable: requires 2 arguments, but 1 was provided
lock(_L0& __l0, _L1& __l1)
^
/Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/include/mutex:446:1: note: candidate function template not viable: requires at least 3 arguments, but 1 was provided
lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
^
3 errors generated.
--
Compilation failed unexpectedly!Comment Actions Hmm, std::scoped_lock is only available with C++17. I'll put an #ifdef around it if you don't mind. Comment Actions #if TEST_STD_VER >= 17 is what you're looking for. And don't forget to `#include "test_macros.h". Comment Actions Ok, I cleaned this up a bit in rCXX344194. I hope you don't mind, the change is rather small. | ||||||||||||