1 // { dg-do run } 2 3 #include <omp.h> 4 #include <assert.h> 5 6 struct B 7 { 8 static int count; 9 static B *expected; 10 11 B& operator=(const B &); 12 }; 13 14 int B::count; 15 B * B::expected; 16 17 B& B::operator= (const B &b) 18 { 19 assert (&b == expected); 20 assert (this != expected); 21 #pragma omp atomic 22 count++; 23 return *this; 24 } 25 26 static int nthreads; 27 foo()28void foo() 29 { 30 #pragma omp parallel 31 { 32 B b; 33 #pragma omp single copyprivate(b) 34 { 35 nthreads = omp_get_num_threads (); 36 B::expected = &b; 37 } 38 } 39 } 40 main()41int main() 42 { 43 omp_set_dynamic (0); 44 omp_set_num_threads (4); 45 foo(); 46 47 assert (B::count == nthreads-1); 48 49 return 0; 50 } 51