diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/shared_lock/cons/lwg4172.cc | 28 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/unique_lock/cons/lwg4172.cc | 27 |
2 files changed, 55 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/30_threads/shared_lock/cons/lwg4172.cc b/libstdc++-v3/testsuite/30_threads/shared_lock/cons/lwg4172.cc new file mode 100644 index 0000000..0a3bf10 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/shared_lock/cons/lwg4172.cc @@ -0,0 +1,28 @@ +// { dg-do run { target c++14 } } + +// LWG 4172. unique_lock self-move-assignment is broken + +#include <shared_mutex> +#include <testsuite_hooks.h> + +void +test_self_move() +{ + struct Lockable + { + bool locked = false; + void lock_shared() { locked = true; } + void unlock_shared() { locked = false; } + bool try_lock_shared() { if (locked) return false; return locked = true; } + }; + + Lockable x; + std::shared_lock<Lockable> l(x); + l = std::move(l); + VERIFY(x.locked); +} + +int main() +{ + test_self_move(); +} diff --git a/libstdc++-v3/testsuite/30_threads/unique_lock/cons/lwg4172.cc b/libstdc++-v3/testsuite/30_threads/unique_lock/cons/lwg4172.cc new file mode 100644 index 0000000..37542b5 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/unique_lock/cons/lwg4172.cc @@ -0,0 +1,27 @@ +// { dg-do run { target c++11 } } + +// LWG 4172. unique_lock self-move-assignment is broken + +#include <mutex> +#include <testsuite_hooks.h> + +void +test_self_move() +{ + struct Lockable + { + bool locked = false; + void lock() { locked = true; } + void unlock() { locked = false; } + }; + + Lockable x; + std::unique_lock<Lockable> l(x); + l = std::move(l); + VERIFY(x.locked); +} + +int main() +{ + test_self_move(); +} |