[PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 11 10:56:32 PST 2016


EricWF added a comment.

Unfortunately the discussion was offline so it's not available.

Anybody using `std::mutex` with `std::unique_lock` or their own lock guards will probably experience some breakage.

Heres an example of code that will now not compile with "-Werror=thread-safety"

  std::mutex m;
  m.lock();
  {
    std::unique_lock<std::mutex> g(m, std::adopt_lock);
  }  // -Wthread-safety thinks `m` is still locked

AFAIK we can't fully annotate `std::unique_lock` either because there is no way to model the deferred locking behavior.


http://reviews.llvm.org/D14731





More information about the cfe-commits mailing list