/* TAGS: min */ /* VERIFY_OPTS: -o nofail:malloc */ /* CC_OPTS: */ // V: mutex@safety CC_OPT: -DEXTRA_MUTEX // V: atomic@safety // V: mutex@local=!cwait CC_OPT: -DEXTRA_MUTEX V_OPT: --nontermination local,~condition-wait ERR: error trace: thread join // V: mutex@local=!join CC_OPT: -DEXTRA_MUTEX V_OPT: --nontermination local,~thread-join ERR: error trace: condition variable // V: mutex@local=all CC_OPT: -DEXTRA_MUTEX V_OPT: --nontermination local ERR: error trace: termsec check begin // V: mutex@global CC_OPT: -DEXTRA_MUTEX V_OPT: --nontermination global ERR: error trace: .* // V: atomic@local=!cwait V_OPT: --nontermination local,~condition-wait ERR: error trace: thread join // V: atomic@local=!join V_OPT: --nontermination local,~thread-join ERR: error trace: condition variable // V: atomic@local=all V_OPT: --nontermination local ERR: error trace: termsec check begin // V: atomic@global V_OPT: --nontermination global ERR: error trace: .* #include #include #include #include #include int main() { std::mutex mtx; std::condition_variable cvar; #ifdef EXTRA_MUTEX int x = 0; #else std::atomic< int > x{ 0 }; #endif std::thread t( [&] { std::unique_lock guard( mtx ); cvar.wait( guard, [&] { return x > 0; } ); } ); { cvar.notify_one(); #ifdef EXTRA_MUTEX std::lock_guard _( mtx ); #endif ++x; } t.join(); }