### GCC BUG

#include <condition_variable>
#include <mutex>

void foo()
{
std::mutex mtx;
std::unique_lock<std::mutex> lk(mtx);
std::condition_variable cond;
while (true)
{
cond.wait(lk);
}
}

int main()
{
t.join();
}


• 不加上sleep_for，那么程序会在执行到join时收到SIGSEGV
• 加上sleep_for，那么程序会在执行wait时收到SIGSEGV

• Calling this function if lock.mutex() is not locked by the current thread is undefined behavior.
• Calling this function if lock.mutex() is not the same mutex as the one used by all other threads that are currently waiting on the same condition variable is undefined behavior.