This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
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?
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. ...