From the documentation on ctime
:
The returned value points to an internal array whose validity or value may be altered by any subsequent call to asctime or ctime.
The order of evaluation of subexpressions within the expression is unspecified. In particular, it is legal for the compiler to call ctime
twice first, then call operator<<
as necessary. This is what seems to happen in your case.