Using g++ to declare function-static thread-local storage:
void f() {
static __thread somePodStruct thing;
...
}
can I assume that thing
will get zero-initialized?
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.