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
$ gcc --version
gcc (GCC) 4.2.1 20070719 (rpm:3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$


-- 
           Summary: "#pragma omp for firstprivate(shared_var)" in function
                    labelled 'shared_var' as private
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geir at cray dot com


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

Reply via email to