As reported by Ignacio Fernández Galván, the following program prints with "gfortran -fopenmp" 0.0 instead of 42.0. Without -fopenmp or using, e.g., ifort or sunf95 42.0 is printed. See also http://gcc.gnu.org/ml/fortran/2008-02/msg00058.html I believe the program is valid, compare also http://www.openmp.org/pipermail/omp/2006/000532.html PROGRAM Outer IMPLICIT NONE REAL, DIMENSION(20) :: A INTEGER :: k A = 0.0 !$OMP PARALLEL DO PRIVATE(k) DO k=1,SIZE(A) CALL Inner(k) END DO !$OMP END PARALLEL DO print *, A CONTAINS SUBROUTINE Inner(i) IMPLICIT NONE INTEGER :: i A(i) = 42 END SUBROUTINE Inner END PROGRAM Outer
*** Bug 35133 has been marked as a duplicate of this bug. ***
*** Bug 35131 has been marked as a duplicate of this bug. ***
I have managed to reduce it a bit more, and it does not involve passing the loop variable as an argument: program outer integer k, a(1) a = 0.0 !$OMP PARALLEL DO do k = 1, 1 call inner end do !$OMP END PARALLEL DO print *, a(1) contains subroutine inner a(1) = 42 end subroutine inner end program outer From the tree dump, I've made the following C testcase which also exhibits the same bug: $ cat u.c int main (void) { int a[1], k; void inner (void) { a[0] = 42; } a[0] = 0; #pragma omp parallel #pragma omp for private(k) nowait for (k = 1; k <= 1; k = k + 1) inner (); __builtin_printf ("%d\n", a[0]); return 0; } $ gcc -fopenmp u.c && ./a.out 0 There is no OpenMP component, and since I'm not sure the C code I have created is valid, I leave this bug as "fortran" for now... but I think it's a generic issue of contained functions.
Subject: Bug 35130 Author: jakub Date: Fri Feb 15 17:36:43 2008 New Revision: 132349 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132349 Log: PR middle-end/35130 * tree-nested.c (convert_call_expr): Put FRAME.* vars into OMP_CLAUSE_SHARED rather than OMP_CLAUSE_FIRSTPRIVATE clause. * testsuite/libgomp.fortran/pr35130.f90: New test. * testsuite/libgomp.c/pr35130.c: New test. Added: trunk/libgomp/testsuite/libgomp.c/pr35130.c trunk/libgomp/testsuite/libgomp.fortran/pr35130.f90 Modified: trunk/gcc/ChangeLog trunk/gcc/tree-nested.c trunk/libgomp/ChangeLog
Fixed on the trunk.
Fixed for real.
*** Bug 36351 has been marked as a duplicate of this bug. ***