[Bug libstdc++/57641] std::timed_mutex.try_lock_until() is broken

mustrumr97 at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 18 17:22:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57641

--- Comment #2 from Hristo Venev <mustrumr97 at gmail dot com> ---
Am I very stupid, or is

#include <mutex>
#include <chrono>
using Clock=std::chrono::steady_clock;
int main(){
    std::timed_mutex m;
    m.lock();
    Clock::time_point tp=Clock::now()+std::chrono::seconds(2);
    if(m.try_lock_until(tp)) return 1;
    return 0;
}

supposed to run for ~2s and return 0?
With clang++ -stdlib=libc++ it works as I expect.
With clang++ -stdlib=libstdc++ and with g++ it returns 1 after 0.001s.

The result is the same for std::chrono::high_resolution_clock.

The test from cppreference.com is very similar.
http://en.cppreference.com/w/cpp/thread/timed_mutex/try_lock_until

What the hell is going on?



More information about the Gcc-bugs mailing list