Static Analysis Problem Type Reference
A loop variable may not appear in OpenMP* THREADPRIVATE clause.
The THREADPRIVATE directive specifies a list of variables that should be replicated, with each thread having its own copy. Such variables are unsuited for use as parallel Loop variables, and the OpenMP* specification forbids such usage.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
OpenMP declaration |
The location of the Loop directive |
#include <stdio.h>
#include <omp.h>
int i;
#pragma omp threadprivate(i)
int main(int argc, char **argv)
{
// Bad: threadprivate variable cannot be used
// as a loop counter in a parallel loop.
#pragma omp parallel for ordered
for (i = 1; i < 100; i++) {
#pragma omp ordered
printf("test: %d\n", i);
}
return 0;
}