Skip to content

Commit 89c57ea

Browse files
WalterBrightdlang-bot
authored andcommitted
fix Local Static Variables section
1 parent 27ea6a9 commit 89c57ea

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spec/function.dd

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,11 +2167,14 @@ void func(int x)
21672167

21682168
$(H3 $(LEGACY_LNAME2 Local Static Variables, local-static-variables, Local Static Variables))
21692169

2170-
$(P Local variables in functions can be declared as static
2171-
or $(D __gshared) in which case they are statically allocated
2172-
rather than being allocated on the stack.
2173-
As such, their value persists beyond the exit of the function.
2174-
)
2170+
$(P Local variables in functions declared as `static`, `shared static`
2171+
or $(D __gshared) are statically allocated
2172+
rather than being allocated on the stack.
2173+
The lifetime of `__gshared` and `shared static` variables begins
2174+
when the function is first executed and ends when the program ends.
2175+
The lifetime of `static` variables begins when the function is first
2176+
executed within the thread and ends when that thread terminates.
2177+
)
21752178

21762179
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
21772180
---
@@ -2185,8 +2188,7 @@ void foo()
21852188
)
21862189

21872190
$(P The initializer for a static variable must be evaluatable at
2188-
compile time, and they are initialized upon the start of the thread
2189-
(or the start of the program for $(D __gshared)).
2191+
compile time.
21902192
There are no static constructors or static destructors
21912193
for static local variables.
21922194
)

0 commit comments

Comments
 (0)