Variant of Example 15.3c from Openmp 4.5 spec examples

HI all,

I am experiencing a seg fault with a program similar to the one mentioned in the subject.

My program looks like the following (I am using clang 6.0.):

Hi Simone,

first I could not find the example you referenced.

Are you talking about this document?
https://www.openmp.org/wp-content/uploads/openmp-examples-4.5.0.pdf

After some tests together with Jonas, we found that clang makes variable shared instead of firstprivate as suggested by the specification of "implicitly determined data-sharing attributes":

> In a task generating construct, if no default clause is present, a
> variable for which the data-sharing attribute is not determined by the
> rules above is firstprivate.

clang 7.0 shows the same behavior.

Compiling with gcc + icc does not result in an issue.

The behavior is also broken for private variables that have definitely no dynamic storage duration (just to exclude that the pointer is the problem):

int main() {

#pragma omp parallel num_threads(NUM_THREADS)
   {
     int P = omp_get_thread_num();
     printf("%d: %d\n", omp_get_thread_num(), P);

#pragma omp task
     {
#pragma omp critical
       {
         printf("%d: %d\n", omp_get_thread_num(), P);
         P += 10;
       }
     }
#pragma omp barrier
     printf("%d: %d\n", omp_get_thread_num(), P);
   }
}

For firstprivate, the change of P should have no effect outside of the task.

This seems to be a codegen problem.
Can you file a bugreport?

Best
Joachim

Hi Joachim.

Sorry the document was the 4.0 not the 4.5. Anyway, my example was a variant of the example 15.3c.

Thanks you for confirming, I was able to make it work only with gcc and icc as well.
I'll file a bug report.

Thanks!
Simone