Title
thread_local dynamic initialization
Status
open
Section
6.9.3.3 [basic.start.dynamic]
Submitter
Jason Merrill

Created on 2023-01-06.00:00:00 last changed 2 weeks ago

Messages

Date: 2023-01-15.12:07:04

Suggested resolution:

Change in 6.9.3.3 [basic.start.dynamic] paragraph 7 as follows:

It is implementation-defined whether the dynamic initialization of a non-block non-inline variable with thread storage duration is sequenced before the first statement of the initial function of a thread or is deferred. If it is deferred, the initialization associated with the entity for thread t is sequenced before the first non-initialization odr-use by t of any non-inline variable with thread storage duration and dynamic initialization defined in the same translation unit as the variable to be initialized. ...
Date: 2023-01-06.00:00:00

Subclause 6.9.3.3 [basic.start.dynamic] paragraph 7 specifies:

It is implementation-defined whether the dynamic initialization of a non-block non-inline variable with thread storage duration is sequenced before the first statement of the initial function of a thread or is deferred. If it is deferred, the initialization associated with the entity for thread t is sequenced before the first non-initialization odr-use by t of any non-inline variable with thread storage duration defined in the same translation unit as the variable to be initialized. ...

How does the rule quoted above affect variables declared constinit? For example:

  extern thread_local constinit int x;

Clang and gcc do not emit suitable wrapper code to allow for deferred initialization of x, which is non-conforming. Should this be allowed?

History
Date User Action Args
2023-01-15 12:07:04adminsetmessages: + msg7138
2023-01-06 00:00:00admincreate