On 2/5/2024 11:10 PM, Chris M. Thomasson wrote:
[...]
Okay, made some progress. Here is a little example of where the warnings
pop up. "Sketchy" use of std::unique_lock, well, imvvho that is:
___________________________________________
#include <iostream>
#include <functional>
#include <thread>
#include <mutex>
#include <cassert>
namespace ct
{
struct mutex_test
{
std::mutex m_mutex;
void
bar(std::unique_lock<std::mutex>& lock)
{
assert(lock);
lock.unlock();
}
void
foo()
{
std::unique_lock<std::mutex> lock(m_mutex);
// lock will be unlocked after this call!
bar(lock);
lock.lock(); // Yup...
}
};
}
int
main()
{
std::cout << "ct_threads... ;^)\n" << std::endl;
{
ct::mutex_test test;
test.foo();
}
return 0;
}
___________________________________________
Interesting wrt MSVC.