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 first use” means “at any point as long as it is before” rather than does “just before”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)