https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27557
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> --- It actually is hard, otherwise it would be done sooner. There is easy workaround, one can declare the var before actually defining, extern whatever var; #pragma omp threadprivate(var) whatever var; or once OpenMP 5.1 C++ attributes are implemented through whatever var [[omp::directive(threadprivate(var))]]; because in that case threadprivate is visible right on the var definition. The problem is that right now the construction of vars acts as a variable use and it is impossible to distinguish between such definition and some other uses of the variable in between its definition and the threadprivate directive.