Static Analysis Problem Type Reference
Pointers are not allowed in an OpenMP* FIRSTPRIVATE clause.
The rules for the FIRSTPRIVATE clause for C/C++ are:
For FORTRAN, the rules are:
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
OpenMP usage error |
The location of the FIRSTPRIVATE clause |
#include <stdio.h>
#include <omp.h>
int sum = 0;
int a[100] = {0};
int *pntr = a;
int main(int argc, char **argv)
{
int i;
#pragma omp parallel for firstprivate(pntr) reduction(+:sum)
for (i = 1; i < 100; i++) {
// INCORRECT: firstprivate variable must not have a reference type
sum = sum + *pntr;
}
return 0;
}