Hi, I've run into a problem where omp_in_parallel() is returning 0 where I expect it to return 1. The minimal working example is: #include #include #include const std::size_t problem_size = 10000; int main(void) {   std::vector parallel_checks(problem_size, false); #pragma omp parallel for   for (std::size_t i = 0; i < problem_size; i++) {     parallel_checks[i] = omp_in_parallel();   }   for (std::size_t i = 0; i < problem_size; i++) {     if (!parallel_checks[i]) {       std::cout << "failed at i = " << i << "\n";     }   }   return 0; } where parallel_checks[i] should be true for all i. This fails only inconsistently so I've attached a slightly longer version that runs this check thousands of times. On my personal computer (4 cores, g++ 9.3.0), it fails about 10-30 times out of 100,000 attempts (failure meaning that any element in parallel_checks[] is false). On a supercomputing node I have access to (64 cores, g++ 11.2.0), it fails much more frequently (300-900 attempts out of 1000). I've tested this across optimization settings and while the numbers vary a bit, it is always a problem even without optimizations on. Am I misunderstanding what omp_in_parallel() is supposed to provide? Does it not guarantee a true value at any point inside a parallel section? Thanks for your help. Best, - Matthias