Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Does "§6.7 [stmt.dcl] p4 If control enters the declaration concurrently while the variable is being initialized, the concurrent execution shall wait for completion of the initialization.", this also apply to global static variables? Thanks Commented Apr 29, 2020 at 13:28
  • @Rick static on a global variable means something different: the variable has internal linkage. Only the translation unit containing the variable can see and directly interact with it. Note that if you have the same identifier in multiple translation units they are all different instances with the same name and static prevents them from colliding when the linker assembles the program. It can only be initialized once at program start-up so threading is not an issue. Commented Aug 12, 2021 at 22:45