------- Comment #3 from jakub at gcc dot gnu dot org 2008-05-23 09:12 ------- Reduced testcase:
struct A { ~A (); }; struct B { explicit B (const A &x = A ()) : a (x) { } A a; }; B var; void bar (); void foo () { #pragma omp parallel private (var) bar (); } Note that your example is very buggy. First of all, data sharing clauses on #pragma omp parallel only affect the uses of the variable within the construct, they have no effect on variables in other functions. So the private (localTodoStack) clause really doesn't have the desired effect (a private variable will be constructed, but nothing will ever use it) - localTodoStack in quick_sort is still a shared global variable. If you want it to be private, you should pass it by reference to quick_sort, or use threadprivate var, or perhaps the easiest just use an automatic variable in quick_sort function. Second bug is if (true == globalTodoStack.empty()) { outside of critical region, as globalTodoStack is shared, calling this is really racy, generally it could crash, in g++ as it just compares two pointers it could just say globalTodoStack is empty even when it is not, or vice versa. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36237