https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33719

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-07-25
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Geir Johansen from comment #0)
> This case involves a function containing only a '#pragma omp for' directive
> and a 'for' loop to go with it.  The invoking routine is the one that
> determines whether the variable is shared or private.  There is no way to
> supply this information within the function without expanding what the
> function does. 
> 
> $ cat >bug2874.c
> /*  derived from ISU's tests RTED_OpenMP/C/SECTION_B/c_B_7_3_e_D_s.c
>                                     c_B_7_3_f_D_s.c, c_B_7_3_g_D_s.c   */
> #include <omp.h>
> #define N 17
> 
> void sub(double *shared_var,double result_var[],int thread_num){
>     int i = 0;
> 
>     #pragma omp for firstprivate(shared_var)
>     for (i=0;i<N;i++){
>         result_var[thread_num] = *shared_var;
>     }
> }
> 
> $ gcc -c -fopenmp bug2874.c
> bug2874.c: In function 'sub':
> bug2874.c:9: error: firstprivate variable 'shared_var' is private in outer
> context

Confirmed that this error still occurs; albeit now with a caret:

$ /usr/local/bin/gcc -c -fopenmp 33719.c
33719.c: In function ‘sub’:
33719.c:9:9: error: firstprivate variable ‘shared_var’ is private in outer
context
 #pragma omp for firstprivate(shared_var)
         ^~~

Reply via email to