Should g ++ thread variables follow default initialization rules?

Using g ++ to declare spatially static local storage:

void f() {
    static __thread somePodStruct thing;
    ...
}

Is it possible to assume that it thingwill receive zero initialization?

+3
source share
1 answer

According to the GCC documentation:

http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Thread-Local.html

In C ++, if an initializer is present for a local local variable, it must be a constant expression, as defined in 5.19.2 of the ANSI / ISO C ++ standard.

, .
, , - , , .

+2

Source: https://habr.com/ru/post/1752737/


All Articles