https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27557
Yves Vandriessche <yves.vandriessche at intel dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yves.vandriessche at intel dot com --- Comment #18 from Yves Vandriessche <yves.vandriessche at intel dot com> --- As mentioned by Sameer, thread_local now works, but the threadprivate OpenMP directive still fails with a "declared 'threadprivate' after first use" error. My test fragment, is as follows. It should only print a single "ctor" and twice the same set of distinct pointers: #include <cstdio> #include <omp.h> struct Foo { Foo() {puts("ctor");} int a; }; int bar() { int sum=0; // // alternative to omp threadprivate, works with gcc // thread_local Foo local; #pragma omp parallel reduction(+:sum) { static Foo local; #pragma omp threadprivate(local) local.a = omp_get_thread_num(); printf("%p\n", &local); sum += local.a; } printf("%d\n", sum); return sum; } int main(int argc, char** argv) { bar(); bar(); return 0; }