#1652 system_clock::to_time_t can not handle "time_point::min"

OTHER
open
nobody
Bug
none
Unknown
False
2014-12-01
2012-07-05
Anonymous
No

Passing of the std::chrono::system_clock::min() time point to the std::chrono::system_clock::to_timet function results in a logical error exception being thrown and abnormal termination of the execution runtime.

This bug seems to affect Windows operating systems in general; I'm not entirely certain whether this is a bug in how the underlying operating system is exposing itself, or how the MinGW runtime for C++11 is handling the issue. The compiler & libraries however report they support this use of the chrono functions.

Here is my full code:

#include <string>
#include <iostream>
#include <chrono>
#include <ctime>

using namespace std;
using namespace std::chrono;

const string asString (const system_clock::time_point& p_TimePoint)
{
string l_timeString ("");
try
{
time_t l_time = system_clock::to_time_t(p_TimePoint);
l_timeString = ctime(&l_time);
if ( l_timeString.size() > 0 )
{
l_timeString.resize(l_timeString.size()-1);
}
}
catch (exception& l_ex)
{
cout << "Ex: " << l_ex.what() << endl;
}
return l_timeString;
}

void shoo ()
{
try
{
system_clock::time_point l_tp;
cout << "Epoch: " << asString(l_tp) << endl;

    l\_tp = system\_clock::now\(\);
    cout &lt;&lt; "Now: " &lt;&lt; asString\(l\_tp\) &lt;&lt; endl;

    l\_tp = system\_clock::time\_point::min\(\);
    cout &lt;&lt; "Min: " &lt;&lt; asString\(l\_tp\) &lt;&lt; endl;

    l\_tp = system\_clock::time\_point::max\(\);
    cout &lt;&lt; "Max: " &lt;&lt; asString\(l\_tp\) &lt;&lt; endl; 
\}
catch \(exception& l\_ex\)
\{
    cout &lt;&lt; "Ex: " &lt;&lt; l\_ex.what\(\) &lt;&lt; endl;
\}

}

int main ()
{
shoo();
cout << "Done, press ENTER" << endl;
cin.get();
return 0;
}

However, you will only be interested in the line:

time_t l_time = system_clock::to_time_t(p_TimePoint);

And then only when passing in the time point:

l_tp = system_clock::time_point::min();
cout << "Min: " << asString(l_tp) << endl;

This same code works on other platforms - Ubuntu G++ for instance without problems.

My build command line parameters are very simple: g++ -x c++ -Wall -std=c++11 Test.cpp -o Test.exe

My MinGW version: Comes from "mingw-get-inst-20120426", and is 4.7.0
The C++ library in use is: libstdc++-6.dll
The gcc library in use is: libgcc_s_dw2-1.dll

My Operating System is: Windows Vista 64bit Ultimate

My machine specification is: Intel Core i7QM - 2.6ghz - 8GB DDR3 RAM - yadda yadda yadda

You may find more detailed information about this problem on my personal blog: http://megalomaniacbore.blogspot.co.uk/2012/07/mingw-c11-chrono-library-bug.html

Tracker status: I have searched the trackers for references to this problem, I have also tried to discover whether this project tracker is actually interested in STL implementation bugs like this, so please, if I'm in the wrong location, be so kind as to let me know and close the ticket. Thanks :)

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-05

    My Test Code, as per post and bug tracked entry.

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-05
    • summary: system_clock::to_time_t can not handle "time_position::min" --> system_clock::to_time_t can not handle "time_point::min"
     
  • Earnie Boyd

    Earnie Boyd - 2012-07-05

    llibstdc++ is a GCC product. You'll most likely get better help on the bugs list for GCC. It could be an underlying problem with the MSVCRT but you'll need to chase down the origin of the stdc++ library calls to determine how the functions are implemented.

     
  • Earnie Boyd

    Earnie Boyd - 2012-07-05
    • labels: 104601 --> gcc-4.7.0
     
  • Earnie Boyd

    Earnie Boyd - 2012-10-23
    • status: open --> pending
     
  • Earnie Boyd

    Earnie Boyd - 2012-10-23

    Need to research GCC bug tracker.

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-11
    • labels: gcc-4.7.0 --> gcc-4.7.0, gcc
    • status: pending --> open
    • milestone: --> OTHER
    • type: --> Bug
    • resolution: --> none
    • category: --> Unknown
    • patch_attached: --> False
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks