Skip to content

Commit

Permalink
fix Issue 2382 - spec is not clear on what is allowed as global/stati…
Browse files Browse the repository at this point in the history
…c initializers
  • Loading branch information
WalterBright committed Jan 22, 2012
1 parent 83763c1 commit a23ff98
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions declaration.dd
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,12 @@ $(GNAME VoidInitializer):
$(B void)
)

Normally, variables are initialized either with an explicit
$(P Normally, variables are initialized either with an explicit
$(I Initializer) or are set to the default value for the
type of the variable. If the $(I Initializer) is $(B void),
however, the variable is not initialized. If its value is
used before it is set, undefined program behavior will result.
)

-------------------------
void foo() {
Expand All @@ -633,8 +634,18 @@ void foo() {
}
-------------------------

Therefore, one should only use $(B void) initializers as a
$(P Therefore, one should only use $(B void) initializers as a
last resort when optimizing critical code.
)

<h3>Global and Static Initializers</h3>

$(P The $(GLINK Initializer) for a global or static variable must be
evaluatable at compile time.
Whether some pointers can be initialized with the addresses of other
functions or data is implementation defined.
Runtime initialization can be done with static constructors.
)

)

Expand Down

0 comments on commit a23ff98

Please sign in to comment.