Using g++ to declare function-static thread-local storage:
void f() {
static __thread somePodStruct thing;
...
}
can I assume that thing will get zero-initialized?
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 thread-local variable, it must be a constant-expression, as defined in 5.19.2 of the ANSI/ISO C++ standard.
So you can explicitly set it to zero.
So to be on the safe side with no down side of any assumptions you can get zero initialization be explicitly doing it yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With