http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48716
Summary: gcc OpenMP static variable declared in scope inside construct is predetermined shared Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: g...@cray.com A static variable is declared inside a task construct having a default(none) clause. The OpenMP API says that this variable is predetermined shared. Currently the GNU gcc compiler wants this variable to appear in a SHARED clause. The OpenMP API version 3.0 (May 2008) on p. 78 lines 10 & 20 states: "The following variables have predetermined data-sharing attributes: . . . * Static variables which are declared in a scope inside the construct are shared." On p. 87 lines 22-25 the following appears: "The default(none) clause requires that each variable that is referenced in the construct, and that does not have a predetermined data-sharing attribute, must have its data-sharing attribute explicitly determined by being listed in a data-sharing attribute clause." In Section 2.7 task Construct on p. 59, line 17, we see that the default(none) clause may appear on the #pragma omp task construct. Test case: $ cat ISU3305.c // derived from OpenMP test omp3c/c03_2_9_3_1_3k.c // REFERENCES : OpenMP 3.0, p. 59, line 17 // OpenMP 3.0, p. 78, line 20 // OpenMP 3.0, p. 87, lines 22-25 int main(void) { #pragma omp task default(none) { static int shared_var; shared_var = 1; } return 0; } $ gcc --version gcc (GCC) 4.6.0 20110325 (Cray Inc.) Copyright (C) 2011 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. $ gcc -c -fopenmp ISU3305.c ISU3305.c: In function 'main': ISU3305.c:9:20: error: 'shared_var' not specified in enclosing parallel ISU3305.c:6:13: error: enclosing task $ Expected results from Intel and PGI compilers: $ pgcc -c -mp ISU3305.c $ icc -c -openmp ISU3305.c $