When is a `thread_local` global variable initialized?
The standard allows for this behavior, although it doesn’t guarantee it. From 3.7.2/2 [basic.stc.thread]: A variable with thread storage duration shall be initialized before its first odr-use (3.2) and, if constructed, shall be destroyed on thread exit. It’s also possible that the objects are constructed at some other time (e.g. on program startup), as “before … Read more