You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that returning a reference to a protected variable in general might be incorrect, but in this case before returning the reference I call a function with assert_exclusive_lock annotation, so by the time we get to the return statement, clang should be able to figure out that the lock is being held.
Naturally, replacing assert_exclusive_lock with exclusive_locks_required attribute eliminates the warning. However, in more complex cases it might be hard for clang to figure out what locks are held in what contexts, so I want to help clang with putting asserts like this to let clang know that the lock is actually held, but it does not seem that clang takes those into account or derives anything from exclusive_locks_required, which seems wrong.
Is my understanding of the purpose of exclusive_locks_required annotation somehow incorrect?
The text was updated successfully, but these errors were encountered:
It seems like clang version 18 (specifically I tested it on 18.1.8) fails to take into account
assert_exclusive_lock
/assert_capability
annotations.Here is a minimal example I came up with that reproduces the issue for me:
When compiling this code with the following command:
I get an error:
I understand that returning a reference to a protected variable in general might be incorrect, but in this case before returning the reference I call a function with
assert_exclusive_lock
annotation, so by the time we get to the return statement, clang should be able to figure out that the lock is being held.Naturally, replacing
assert_exclusive_lock
withexclusive_locks_required
attribute eliminates the warning. However, in more complex cases it might be hard for clang to figure out what locks are held in what contexts, so I want to help clang with putting asserts like this to let clang know that the lock is actually held, but it does not seem that clang takes those into account or derives anything fromexclusive_locks_required
, which seems wrong.Is my understanding of the purpose of
exclusive_locks_required
annotation somehow incorrect?The text was updated successfully, but these errors were encountered: