[C++] std::chrono::steady_clock is not steady - by Haegar_tv

Status : 

  Duplicate<br /><br />
		This item appears to be a duplicate of another existing Connect or internal item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 753063 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 7/10/2012 3:48:51 AM
Access Restriction Public


With Visual Studio 2012 (VC11) there is support for the std::chrono library.
As noted in the documentation (http://msdn.microsoft.com/en-us/library/hh874790(v=vs.110).aspx) the std::chrono::steady_clock should be steady.

But thats not true. If you change the system-clock backwards the std::chrono::steady_clock::now() can give a lesser value than before. That's violates the standard and the documentation.

As I looked through the code I see that 'GetSystemTimeAsFileTime' is called for steady_clock, system_lock and high_resolution_clock. But that function is not steady and does not have a high-resolution.

Code-Snippet to reproduce:
auto start = std::chrono::steady_clock::now();
std::chrono::seconds dura( 120 );
std::this_thread::sleep_for( dura );
//During that Sleeping-Period change the system-lock 1h backwards.
auto end = std::chrono::steady_clock::now();
auto timeElapsed = end - start;
//the timeElapsed is totally wrong
Sign in to post a comment.
Posted by Microsoft on 12/3/2012 at 8:34 PM

Thanks for reporting this bug. I'm resolving it as a duplicate of http://connect.microsoft.com/VisualStudio/feedback/details/753115/steady-clock-class-and-clock-function-are-non-conformant-with-c-11-and-c11-standards . Although that Connect bug was filed slightly later, it covers both steady_clock and clock(), so I'd like to use it as the primary.

Note: Connect doesn't notify me about comments. If you have any further questions, please E-mail me.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
Posted by Microsoft on 7/10/2012 at 10:43 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 7/10/2012 at 4:48 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)