Skip to content

Conversation

@Alikhalesi
Copy link
Contributor

@Alikhalesi Alikhalesi commented Jul 9, 2022

Resolves #2848

@Alikhalesi Alikhalesi requested a review from a team as a code owner July 9, 2022 11:08
@ghost
Copy link

ghost commented Jul 9, 2022

CLA assistant check
All CLA requirements met.

@fsb4000

This comment was marked as resolved.

Copy link
Contributor

@fsb4000 fsb4000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for your hard work. I left some comments about the code style.

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Jul 9, 2022
Copy link
Contributor

@MattStephanson MattStephanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're interested, this might be a good opportunity to harmonize the loops here in _Getfmt and in get. I believe the latter is closer to what the Standard requires in [locale.time.get.members]/8. _Getfmt has some additional assumptions for performance purposes, but I think the overall logic should be the same, so it might be more clear and maintainable if the two loops are doing comparable tests in the same order.

If you don't want to go that route, though, I still think it would be better to have _First == _Last as a standalone test at the beginning of the loop, for performance reasons. IOW, if (*_Fmtfirst == '%') would become an else if following the _First == _Last test. Otherwise, we could make several calls to do_get even after the stream is eof.

@Alikhalesi
Copy link
Contributor Author

If you're interested, this might be a good opportunity to harmonize the loops here in _Getfmt and in get. I believe the latter is closer to what the Standard requires in [locale.time.get.members]/8. _Getfmt has some additional assumptions for performance purposes, but I think the overall logic should be the same, so it might be more clear and maintainable if the two loops are doing comparable tests in the same order.

If you don't want to go that route, though, I still think it would be better to have _First == _Last as a standalone test at the beginning of the loop, for performance reasons. IOW, if (*_Fmtfirst == '%') would become an else if following the _First == _Last test. Otherwise, we could make several calls to do_get even after the stream is eof.

Would you suggest a good comment for this standalone test?

@MattStephanson
Copy link
Contributor

Would you suggest a good comment for this standalone test?

This isn't a test as in "unit test", so no comment needed, in my opinion.

Copy link
Contributor

@MattStephanson MattStephanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@StephanTLavavej
Copy link
Member

Looks good to me too. I agree that testing _First == _Last at the beginning of each loop iteration follows [locale.time.get.members]/8 - in particular, that this happens before the whitespace-skipping logic.

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems clearly correct according to the standardese.

@StephanTLavavej StephanTLavavej self-assigned this Jul 13, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 16207c8 into microsoft:main Jul 14, 2022
@StephanTLavavej
Copy link
Member

Thanks for fixing this runtime correctness bug, and congratulations on your second microsoft/STL commit! 🎉 😻 🚀

This will ship in VS 2022 17.4 Preview 2.

@Alikhalesi Alikhalesi deleted the stl_gettime_issue branch July 15, 2022 00:39
fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
…t dereferenceable' when the format is longer than the stream (microsoft#2851)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<xloctime>: time_get::get can still assert 'istreambuf_iterator is not dereferenceable' when the format is longer than the stream

5 participants