Issue |
117480
|
Summary |
[libc++] missing thread safety annotations for std::unique_lock and std::shared_lock
|
Labels |
libc++
|
Assignees |
|
Reporter |
tamird
|
```c++
#include <mutex>
#include <shared_mutex>
class Foo {
int guard() {
std::lock_guard l(lock_);
return state_; // no warning
}
int unique() {
std::unique_lock l(lock_);
return state_; // warning: reading variable 'state_' requires holding shared_mutex 'lock_' [-Wthread-safety-analysis]
}
int shared() {
std::shared_lock l(lock_);
return state_; // warning: reading variable 'state_' requires holding shared_mutex 'lock_' [-Wthread-safety-analysis]
}
private:
int state_ __attribute__((guarded_by(lock_)));
std::shared_mutex lock_;
};
```
https://godbolt.org/z/hq7f9xT9K
Is there a reason these can't be annotated?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs