C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Opt out of multi-threading protection for static variables inside functions

From: Andre Kostur <andre_at_[hidden]>
Date: Sun, 27 Oct 2024 11:32:59 -0700
>
> The point is that it doesn't happen only once. The guard check happens on
> every access


The guard check would be happening on every access anyway. The
initialization of the static still has to be protected in that it only
executes once, just that the initialization itself does not have to be
threadsafe.

Something that bothers me more, however, is that this is potentially adding
more Undefined Behaviour. Where I thought that we were striving to reduce
the amount of Undefined Behaviour in the Standard.

Received on 2024-10-27 18:33:12