I have reduced the problem to the following small code snippet:
struct tls {
~tls() {}
void dont_opt_out() {}
};
thread_local tls tls_obj;
int main(int argc, char **argv) {
tls_obj.dont_opt_out();
}
When executed the program crashes. Why?
I'm using gcc version 4.8.2 on Windows, I compile with g++ -std=c++11 main.cpp
.
Try compiling your code as multi-threaded.
Under Cygwin, it is
-mthreads
option for both compiler and linker.