From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30303 invoked by alias); 27 Jul 2009 17:52:14 -0000 Received: (qmail 30116 invoked by uid 48); 27 Jul 2009 17:52:01 -0000 Date: Mon, 27 Jul 2009 17:52:00 -0000 Subject: [Bug fortran/40876] New: OpenMP private variable referenced in a statement function X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "longb at cray dot com" 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: 2009-07/txt/msg02185.txt.bz2 Beginning with the OpenMP API Version 2.5, this case should fail at compile-time. The gfortran compiler does not reject this case, but gets a segmentation fault at run-time. The OpenMP API Version 3.0 (May 2008) lists the following restriction to a private clause on p 91. lines 29-30: " * Variables that appear in ... expressions for statement function definitions, may not appear in a private clause." Test case: > cat ISU3136.f90 ! derived from OpenMP test omp1/F2_6_2_1_2a.f90 ! According to OpenMP API Ver 2.5 May 2005 p. 75 lines 19/20 ! this is a negative test that should fail at compile-time. use omp_lib implicit none integer, parameter :: NT = 4 integer :: nThreads(NT) integer :: a, st_func, i st_func() = a + 1 !$ call omp_set_dynamic(.false.) !$ call omp_set_num_threads(NT) !$omp parallel private(a) a = omp_get_thread_num() !$omp barrier nThreads(omp_get_thread_num()+1) = st_func() !$omp end parallel do i = 1, NT if(nThreads(i) /= i) then print*, 'FAIL: non-private copy is used in a statement function.' endif enddo END > ftn -o x -fopenmp ISU3136.f90 > aprun -n 1 ./x Application 1190869 exit signals: Segmentation fault Application 1190869 resources: utime 0, stime 0 Expected output (using the Cray compiler) with a compile-time message: > module swap PrgEnv-gnu PrgEnv-cray > ftn -o x -h omp ISU3136.f90 !$omp parallel private(a) ^ ftn-1760 crayftn: ERROR $MAIN, File = ISU3136.f90, Line = 14, Column = 24 "A" is referenced in a statement function expression, so it must not be specified in the PRIVATE, FIRSTPRIVATE or LASTPRIVATE clause. -- Summary: OpenMP private variable referenced in a statement function Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: longb at cray dot com GCC build triplet: x86_64-suse-linux GCC host triplet: x86_64-suse-linux GCC target triplet: x86_64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40876