Skip to content

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Aug 1, 2025

There's only one place in the whole MSVC STL where tm is returned by value. Currently, the tm_isdst member of the variable to return is uninitialized, so it can be sometimes technically UB/EB to return such an object, unless NRVO is done.

I think it's arguably better and clearer to just return a prvalue using designated aggregate initialization, which zero-initializes the tm_isdst member without mentioning it. Note that currently it's only mentioned in a comment among the whole STL.

Edit: Clang doesn't like such implicit zero-initialization. Sigh.

@github-project-automation github-project-automation bot moved this from Initial Review to Work In Progress in STL Code Reviews Aug 2, 2025
@StephanTLavavej StephanTLavavej added enhancement Something can be improved chrono C++20 chrono labels Aug 2, 2025
@StephanTLavavej StephanTLavavej moved this from Work In Progress to Ready To Merge in STL Code Reviews Aug 2, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Aug 7, 2025
@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 93dee9e into microsoft:main Aug 8, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Aug 8, 2025
@StephanTLavavej
Copy link
Member

😸 ⏱️ 📆

@frederick-vs-ja frederick-vs-ja deleted the designated-tm branch August 8, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrono C++20 chrono enhancement Something can be improved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants