https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69183

            Bug ID: 69183
           Summary: ICE when using OpenMP PRIVATE keyword in OMP DO loop
                    not explicitly encapsulated in OMP PARALLEL region
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iain.miller at ecmwf dot int
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 37250
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37250&action=edit
Source code producing ICE with compile line of "gfortran -c -fopenmp
allobs_mod.f90"

When compiling a Fortran90 subroutine that contains OpenMP Do pragmas but not
an explicit OpenMP Parallel region I get an ICE in build_outer_var_ref in
omp-low.c

!=== Start Test Case ===!

module allobs_mod

implicit none

contains

SUBROUTINE EQUIV_TL(NSETOT)

IMPLICIT NONE
INTEGER, INTENT(IN) :: NSETOT
INTEGER :: JSET, IDLEN, ILEN, IMXBDY, IHOFX
REAL,ALLOCATABLE :: ZHOFX(:)

!$OMP DO SCHEDULE(DYNAMIC,1) PRIVATE(JSET,ILEN,IDLEN,IMXBDY,ZHOFX)
DO JSET=1,NSETOT
  ILEN   = JSET
  IDLEN  =ILEN
  IF (MOD(ILEN,2) == 0) IDLEN=IDLEN+1
  IMXBDY = MAX(JSET,1)

  IHOFX=JSET+1
  ALLOCATE(ZHOFX(IHOFX))
  ZHOFX=JSET

  DEALLOCATE(ZHOFX)
ENDDO
!$OMP END DO


END SUBROUTINE EQUIV_TL

end module allobs_mod

!=== End Test Case ===!

Output from compilation:

> gfortran -v -save-temps -c -fopenmp allobs_mod.f90 

Using built-in specs.
COLLECT_GCC=gfortran
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.3.0/configure --prefix=${HOME}/SuSE-gcc530/myinstall
--disable-multilib
Thread model: posix
gcc version 5.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-fopenmp' '-mtune=generic'
'-march=x86-64' '-pthread'
 ${HOME}/SuSE-gcc530/myinstall/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/f951
allobs_mod.f90 -quiet -dumpbase allobs_mod.f90 -mtune=generic -march=x86-64
-auxbase allobs_mod -version -fopenmp -fintrinsic-modules-path
${HOME}/SuSE-gcc530/myinstall/lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/finclude
-o allobs_mod.s
GNU Fortran (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 5.1.2, MPFR version 3.1.2,
MPC version 1.0
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 5.1.2, MPFR version 3.1.2,
MPC version 1.0
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
allobs_mod.f90:18:0:

 !$OMP DO SCHEDULE(DYNAMIC,1) PRIVATE(JSET,ILEN,IDLEN,IMXBDY,ZHOFX)
 ^
internal compiler error: in build_outer_var_ref, at omp-low.c:1206
0x9a822c build_outer_var_ref
        ../../gcc-5.3.0/gcc/omp-low.c:1206
0x9b5d35 lower_rec_input_clauses
        ../../gcc-5.3.0/gcc/omp-low.c:3887
0x9b31df lower_omp_for
        ../../gcc-5.3.0/gcc/omp-low.c:10673
0x9b31df lower_omp_1
        ../../gcc-5.3.0/gcc/omp-low.c:11784
0x9b4ada lower_omp
        ../../gcc-5.3.0/gcc/omp-low.c:11916
0x9b232b lower_omp_1
        ../../gcc-5.3.0/gcc/omp-low.c:11769
0x9b4ada lower_omp
        ../../gcc-5.3.0/gcc/omp-low.c:11916
0x9b22ab lower_omp_1
        ../../gcc-5.3.0/gcc/omp-low.c:11760
0x9b4ada lower_omp
        ../../gcc-5.3.0/gcc/omp-low.c:11916
0x9b22ab lower_omp_1
        ../../gcc-5.3.0/gcc/omp-low.c:11760
0x9b4ada lower_omp
        ../../gcc-5.3.0/gcc/omp-low.c:11916
0x9b232b lower_omp_1
        ../../gcc-5.3.0/gcc/omp-low.c:11769
0x9b4ada lower_omp
        ../../gcc-5.3.0/gcc/omp-low.c:11916
0x9b5240 execute_lower_omp
        ../../gcc-5.3.0/gcc/omp-low.c:11954
0x9b5240 execute
        ../../gcc-5.3.0/gcc/omp-low.c:11991
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

> End

If the PRIVATE variable declaration is removed or the OpenMP region is
explicitly set to be a new PARALLEL region then the code compiles successfully,
but neither of these workarounds should be required nor is the behaviours they
cause desired.

Issue also seen in gfortran 5.2.0, 4.9.1 and 4.8.2 configured on different
systems.

Reply via email to