Compiling the fragment
struct A {
A() {}
};
extern A a;
#pragma omp threadprivate(a)
A a;
with svn from yesterday yields
LANG=C g++-4.2 -fopenmp -c x.cpp -o x.o
x.cpp:6: error: 'a' cannot be thread-local because it has non-POD type 'A'
x.cpp:6: error: 'a' is thread-local and so cannot be dynamically initialized
It works if I remove the definition of a (last line).
I could not find anything in the OpenMP spec (version 2.5) stating that non-POD
threadprivate variables are not allowed. If I change the above to
struct A {
A() {}
};
A a;
#pragma omp threadprivate(a)
I get
LANG=C g++-4.2 -fopenmp -c x.cpp -o x.o
x.cpp:5: error: 'a' declared 'threadprivate' after first use
I believe that both variants are allowed by the OpenMP spec (version 2.5) and
they compile fine with icc 8.1. The spec says something about non-POD
variaables with explicit initializers in section 2.8.2 on page 69, but that
does not apply here. Please correct me if I am wrong.
--
Summary: OpenMP threadprivate directive does not work with non-
POD types
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Georg dot Baum at post dot rwth-aachen dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27557