[llvm-bugs] [Bug 46354] New: Missing warning -Wthread-safety-negative when using capabilities in namespace scope

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 16 18:09:04 PDT 2020


            Bug ID: 46354
           Summary: Missing warning -Wthread-safety-negative when using
                    capabilities in namespace scope
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaronpuchert at alice-dsl.net
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

With mutex.h from https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h
and -Wthread-safety-negative, there is a warning on

class Foo {
  Mutex mu;

  void foo() {
    mu.Lock(); // acquiring mutex 'mu' requires negative capability '!mu'

but not on

Mutex mu;

void foo() {

That's inconsistent, and probably also unintended: "The analyzer assumes that
it holds a negative capability for any object that is not defined within the
current lexical scope. The scope of a class member is assumed to be its
enclosing class, while the scope of a global variable is the translation unit
in which it is defined." [1]


You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200617/1bce0542/attachment.html>

More information about the llvm-bugs mailing list