-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<iomanip>: fixes get_time to parse without delimiters #1280
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
Conversation
11ad53a to
7613ad9
Compare
|
An irrelevant issue I encountered during fixing this issue. I generally use clang-format extension for Visual Studio and apply the .clang-format file using const int _Hi_digits = (_Hi <= 9 ? 1
: _Hi <= 99 ? 2
: _Hi <= 999 ? 3
: _Hi <= 9999 ? 4
: static_cast<int>(_STD log10(_STD abs(_Hi))) + 1);which looks very clear and easy to read. Lines 542 to 545 in 40f2339
I use the latest version of Clang-Format and the VS extension on my system. I'm wondering about the root of this difference and I'm not sure whether something wrong with a configuration on my system or this happening because of the difference between Clang-Format versions on my system and the server. |
|
Different versions of clang-format do change behavior; we are currently using 10.0.0. (Failed clang-format checks will print out the version used; it's the one installed by the VS Preview that we're using.) In theory, if you're using the same version, and you're using the |
StephanTLavavej
left a comment
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 looks good to me - I especially like the set of test cases you've crafted. I'll push a change to simplify the _Hi_digits computation and move this forward to Final Review 😸
CaseyCarter
left a comment
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.
Impressively exhaustive tests!
|
@StephanTLavavej @CaseyCarter |
|
Thanks - both for the additional test case of trailing non-digit characters, and the heads up 😸 |
|
Thanks again for fixing this widely reported runtime correctness bug! Your fix will ship in VS 2019 16.9 Preview 2. 🐈 |
|
The VS 2019 Preview 3 (Visual Studio 2019 Developer Command Prompt v16.9.0-pre.3.0) is installed but the following code cannot parse iso-string properly: std::tm tm{0};
std::istringstream ss(str);
ss >> std::get_time(&tm, "%Y%m%dT%H%M%S");
if (ss.fail())
throw std::invalid_argument("Invalid argument: " + str);
//str = "19700101T000001"Expected: CHECK(tm.tm_sec == 1); //should be 1 second
CHECK(tm.tm_min == 0);Actual: CHECK(tm.tm_sec == 0);
CHECK(tm.tm_min == 1); // 1 min ?The same test works fine for gcc and clang. |
Fixes #944