Boost logo

Boost :

Subject: [boost] [chrono] Possible bug in boost::chrono::process_real_cpu_clock::now() under Windows 32bits
From: ivan.lelann_at_[hidden]
Date: 2012-01-05 10:30:53


As of 1.48 Boost.Chrono contains code below for boost::chrono::process_real_cpu_clock::now()

    clock_t c = ::clock();
    /* ... */
    return time_point(

duration::rep is int64/nanoseconds, clock_t is long. This is VS2008, Win XP 32bits.

I think "c" should be cast to duration::rep before being multiplied.
I randomly get negative time_point and this seems to be fixed by replacing
"c" with "((duration::rep) (c))" in duration constructor :

        duration( ((duration::rep) (c)) *(1000000000l/CLOCKS_PER_SEC))

Can someone confirm my view and that the fix is correct ?


Boost list run by bdawes at, gregod at, cpdaniel at, john at