[llvm-bugs] [Bug 43826] New: Thread Safety Analysis: false positive on const auto scoped_lock variable

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 27 10:17:29 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43826

            Bug ID: 43826
           Summary: Thread Safety Analysis: false positive on const auto
                    scoped_lock variable
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: adi at thingdust.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

$ cat main.cpp 
#include <mutex>

static std::mutex guard;

int main() { const auto lock = std::scoped_lock{guard}; }



$ clang++ -std=c++17 -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wthread-safety
main.cpp 
main.cpp:5:57: warning: releasing mutex 'lock' that was not held
[-Wthread-safety-analysis]
int main() { const auto lock = std::scoped_lock{guard}; }
                                                        ^
1 warning generated.



when the variable is "auto lock" instead of "const auto lock", then no warning
is generated.

-- 
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/20191027/5b082ac8/attachment.html>


More information about the llvm-bugs mailing list