From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20748 invoked by alias); 21 Apr 2011 19:49:35 -0000 Received: (qmail 20739 invoked by uid 22791); 21 Apr 2011 19:49:35 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Apr 2011 19:49:21 +0000 From: "geir at cray dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/48716] New: gcc OpenMP static variable declared in scope inside construct is predetermined shared X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: geir at cray dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 21 Apr 2011 19:49:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg02305.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: geir@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 $