Skip to content

cache __std_get_cvt output - #2596

Closed
Igor Zhukov (fsb4000) wants to merge 3 commits into
microsoft:mainfrom
fsb4000:fix2594
Closed

Igor Zhukov (fsb4000) wants to merge 3 commits into
microsoft:mainfrom
fsb4000:fix2594

Conversation

@fsb4000

@fsb4000 Igor Zhukov (fsb4000) commented Feb 27, 2022

Copy link
Copy Markdown
Contributor

Fixes #2594

Is the warning C4640 correct at all?

If multiple threads attempt to initialize the same static local variable concurrently, the initialization occurs exactly once (since C++11)

https://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables

@fsb4000
Igor Zhukov (fsb4000) requested a review from a team as a code owner February 27, 2022 06:45
Comment thread stl/inc/format Outdated
Comment thread stl/inc/format
Comment on lines +539 to +540
#pragma warning(push)
#pragma warning(disable : 4640) // '_Cvt_cache': construction of local static object is not thread-safe

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This warning indicates that you're using Magic Statics. (It's confusingly phrased - what's happening is that the STL's test suite disables Magic Statics and enables this warning with /w14640 /Zc:threadSafeInit-. This ensures that anything that would be thread-safe via Magic Statics, instead emits this warning.)

We avoid Magic Statics in the STL: #673 (comment)

Thus I believe we need another mechanism here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<format>: Could the output of __std_get_cvt be cached?

3 participants