Affects versions down to at least 4.8 : $ cat z1.f90 subroutine s(x) integer, allocatable :: x(:) integer :: q q = 0 !$omp parallel private(x) reduction(+:q) q = q + sum(x) !$omp end parallel print *, q end $ cat z2.f90 subroutine s(x) integer, allocatable :: x(:) logical :: q q = .false. !$omp parallel private(x) reduction(.or.:q) q = q .or. any (x > 0) !$omp end parallel print *, q end $ _g2d_nofo_v7test -fopenmp -c z1.f90 z1.f90:5:0: !$omp parallel private(x) reduction(+:q) internal compiler error: in gfc_omp_clause_default_ctor, at fortran/trans-openmp.c:471 0x78f7b6 gfc_omp_clause_default_ctor(tree_node*, tree_node*, tree_node*) ../../gcc/fortran/trans-openmp.c:471 0xb25a4b lower_rec_input_clauses ../../gcc/omp-low.c:4953 0xb2a17d lower_omp_taskreg ../../gcc/omp-low.c:15661 0xb1c0e6 lower_omp_1 ../../gcc/omp-low.c:17036 0xb1c0e6 lower_omp ../../gcc/omp-low.c:17180 0xb1b44c lower_omp_1 ../../gcc/omp-low.c:17019 0xb1b44c lower_omp ../../gcc/omp-low.c:17180 0xb1bdec lower_omp_1 ../../gcc/omp-low.c:17028 0xb1bdec lower_omp ../../gcc/omp-low.c:17180 0xb22fcf execute_lower_omp ../../gcc/omp-low.c:17915 0xb22fcf execute ../../gcc/omp-low.c:17952
All releases that I have are affected (4.5.0+).
Created attachment 39689 [details] gcc7-pr77666.patch Untested fix.
Author: jakub Date: Tue Sep 27 07:52:28 2016 New Revision: 240522 URL: https://gcc.gnu.org/viewcvs?rev=240522&root=gcc&view=rev Log: PR fortran/77666 * trans-openmp.c (gfc_omp_private_outer_ref): Return true even for references to allocatable arrays. * gfortran.dg/gomp/pr77666.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/gomp/pr77666.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-openmp.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Wed Dec 7 22:34:05 2016 New Revision: 243388 URL: https://gcc.gnu.org/viewcvs?rev=243388&root=gcc&view=rev Log: Backported from mainline 2016-09-27 Jakub Jelinek <jakub@redhat.com> PR fortran/77666 * trans-openmp.c (gfc_omp_private_outer_ref): Return true even for references to allocatable arrays. * gfortran.dg/gomp/pr77666.f90: New test. Added: branches/gcc-6-branch/gcc/testsuite/gfortran.dg/gomp/pr77666.f90 Modified: branches/gcc-6-branch/gcc/fortran/ChangeLog branches/gcc-6-branch/gcc/fortran/trans-openmp.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed for 6.3+ as well.
Author: jakub Date: Tue May 30 07:29:49 2017 New Revision: 248613 URL: https://gcc.gnu.org/viewcvs?rev=248613&root=gcc&view=rev Log: Backported from mainline 2016-09-27 Jakub Jelinek <jakub@redhat.com> PR fortran/77666 * trans-openmp.c (gfc_omp_private_outer_ref): Return true even for references to allocatable arrays. * gfortran.dg/gomp/pr77666.f90: New test. Added: branches/gcc-5-branch/gcc/testsuite/gfortran.dg/gomp/pr77666.f90 Modified: branches/gcc-5-branch/gcc/fortran/ChangeLog branches/gcc-5-branch/gcc/fortran/trans-openmp.c branches/gcc-5-branch/gcc/testsuite/ChangeLog
Fixed.