-
-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: localtime error #113
fix: localtime error #113
Conversation
@sharkdp,check it pls |
I'm not sure this is the correct way to fix this problem (silencing the warning). How about applying an actual fix (switch to |
I will try it |
@sharkdp, i use localtime_s to fix error, pls check it. |
dbg.h
Outdated
@@ -550,7 +550,12 @@ inline bool pretty_print(std::ostream& stream, const time&) { | |||
const auto us = | |||
duration_cast<microseconds>(now.time_since_epoch()).count() % 1000000; | |||
const auto hms = system_clock::to_time_t(now); | |||
#if _MSC_VER >= 1600 | |||
const auto tm = new std::tm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allocates a new tm
object on the heap and never releases the memory.
dbg.h
Outdated
stream << "current time = " << std::put_time(tm, "%H:%M:%S") << '.' | ||
<< std::setw(6) << std::setfill('0') << us; | ||
|
||
delete tm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you are calling delete
on a tm*
pointer to a static tm
object inside std::localtime
when the #else
branch is active (leading to the CI crashes on non-windows environments). Please don't use new
/delete
at all here but rather simply "stack-allocate" a tm
object locally.
Thank you very much! |
It's my pleasure. |
when environment is win10 and vs2019
i encountered this problem
And add this macro can solve it.