This bug is linked to PR27395 because the same 2 fortran test cases are the ones triggering the problem. (The test cases can be found further bellow or as their equivalents PR27395_1.f90 and PR27395_2.f90 in the libgomp dejagnu testsuite)
Once PR27395 was corrected (Thanks Jakub) I played around with compile options. adding the -fbounds-check options triggers the following ICE for both testcases >> gfortran -v Using built-in specs. Target: i386-linux Configured with: ../gcc/configure --prefix=/cosmic/coudert/tmp/gfortran-20060504/irun --enable-languages=c,fortran --host=i386-linux --with-gmp=/cosmic/coudert/tmp/gfortran-20060504/gfortran_libs Thread model: posix gcc version 4.2.0 20060504 (experimental) >> gfortran -fopenmp -fbounds-check array_reduction1.f90 array_reduction1.f90: In function 'foo1': array_reduction1.f90:24: internal compiler error: in declare_tmp_vars, at gimplify.c:661 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. >> gfortran -fopenmp -fbounds-check array_reduction2.f90 array_reduction2.f90: In function 'foo2': array_reduction2.f90:20: internal compiler error: in declare_tmp_vars, at gimplify.c:661 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. >> more array_reduction1 program array_reduction1 implicit none integer, parameter :: n=10,m=1000 integer :: i integer, dimension(n) :: sumarray ! call foo1(n,m,sumarray) do i=1,n print*,sumarray(i) end do end program array_reduction1 subroutine foo1(n,m,sumarray) use omp_lib, only : omp_get_thread_num implicit none integer, intent(in) :: n,m integer, dimension(n), intent(out) :: sumarray ! integer :: i,j ! sumarray(:)=0 !$OMP PARALLEL DEFAULT(shared) print*,'hello from thread ',omp_get_thread_num() !$OMP DO PRIVATE(j,i), REDUCTION(+:sumarray) do j=1,m do i=1,n sumarray(i)=sumarray(i)+i end do end do !$OMP END DO !$OMP END PARALLEL end subroutine foo ----------------------------------------------------------- >> more array_reduction2.f90 program array_reduction2 implicit none integer, parameter :: n=10,m=1000 integer :: i ! call foo2(n,m) end program array_reduction2 subroutine foo2(n,m) use omp_lib, only : omp_get_thread_num implicit none integer, intent(in) :: n,m ! integer :: i,j integer, dimension(n) :: sumarray ! sumarray(:)=0 !$OMP PARALLEL DEFAULT(shared) print*,'hello from thread ',omp_get_thread_num() !$OMP DO PRIVATE(j,i), REDUCTION(+:sumarray) do j=1,m do i=1,n sumarray(i)=sumarray(i)+i end do end do !$OMP END DO !$OMP END PARALLEL do i=1,n print*,sumarray(i) end do end subroutine foo2 Routines are added again here for completeness -- Summary: ICE on OpenMP array REDUCTION clause and -fbounds-check Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: benjamin dot reveille at gmail dot com GCC build triplet: i386-gnu-linux GCC host triplet: i386-gnu-linux GCC target triplet: i386-gnu-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27446