Issue 127349
Summary Clang thread-safety analysis not producing warnings for multiple objects of the same type
Labels clang
Assignees
Reporter Qwinci
    Given the following code (full code in godbolt link below) Clang doesn't report any warnings for accessing b.some_field even though b.lock is not locked at any point (removing a.lock.acquire() + a.lock.release() calls makes the warning appear but that's obviously not something that you should have to do as they are two distinct objects):
```cpp
struct CAPABILITY("spinlock") Spinlock {
    void acquire() ACQUIRE();
    void release() RELEASE();
};

struct Foo {
    Spinlock lock;
    bool some_field GUARDED_BY(lock);
};

void foobar() {
    Foo a {};
    Foo b {};
    a.lock.acquire();
 b.some_field = true;
 a.lock.release();
}
```
[godbolt](https://godbolt.org/z/dPqb6aqrx)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to