In code like this from include/parallel/workstealing.h (libstdc++ parallel mode)
// After reaching this point, a thread's job list is empty. if (iam_working) { //This thread no longer has work. #pragma omp atomic busy--; iam_working = false; } the instruction belonging to the omp atomic pragma is skipped by the compiler, i. e. busy is _not_ decremented. Adding pragma omp flush before and after does not help either. Replacing the two lines by "__sync_fetch_and_add(&busy, -1);" makes the program work correctly. Unfortunately, I have not yet succeeded in constructing a test case simpler than calling e. g. parallel for_each, and checking the result. The problem could maybe be caused by incorrect inlining. -- Summary: [libgomp/parallel mode] pragma omp atomic broken Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: singler at ira dot uka dot de GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33894