Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Clang thread-safety analysis not producing a warning for accessing a guarded field in different object #127349

Copy link
Copy link
Open
@Qwinci

Description

@Qwinci
Issue body actions

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):

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.