This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33719] "#pragma omp for firstprivate(shared_var)" in function labelled 'shared_var' as private
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Jul 2017 00:31:31 +0000
- Subject: [Bug c/33719] "#pragma omp for firstprivate(shared_var)" in function labelled 'shared_var' as private
- Auto-submitted: auto-generated
- References: <bug-33719-4@http.gcc.gnu.org/bugzilla/>
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)
^~~