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

            Bug ID: 68283
           Summary: ice: gfc_variable_attr(): Bad array reference
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Joost.VandeVondele at mat dot ethz.ch
  Target Milestone: ---

autoreducing a testcase I ran into this ice with current trunk:

> gfortran  -c -g -O3  -cpp  bug.f90
[...]
f951: internal compiler error: gfc_variable_attr(): Bad array reference
0x5db0ba gfc_internal_error(char const*, ...)
        ../../gcc/gcc/fortran/error.c:1295
0x630689 gfc_variable_attr(gfc_expr*, gfc_typespec*)
        ../../gcc/gcc/fortran/primary.c:2272
0x630843 gfc_expr_attr(gfc_expr*)
        ../../gcc/gcc/fortran/primary.c:2351
0x66663e gfc_check_dependency(gfc_expr*, gfc_expr*, bool)
        ../../gcc/gcc/fortran/dependency.c:1292
0x666772 gfc_check_dependency(gfc_expr*, gfc_expr*, bool)
        ../../gcc/gcc/fortran/dependency.c:1260
0x7019ad optimize_assignment
        ../../gcc/gcc/fortran/frontend-passes.c:1162
0x7019ad optimize_code
        ../../gcc/gcc/fortran/frontend-passes.c:206
0x7049f9 gfc_code_walker(gfc_code**, int (*)(gfc_code**, int*, void*), int
(*)(gfc_expr**, int*, void*), void*)
        ../../gcc/gcc/fortran/frontend-passes.c:3262
0x705a14 optimize_namespace
        ../../gcc/gcc/fortran/frontend-passes.c:986
0x705a48 optimize_namespace
        ../../gcc/gcc/fortran/frontend-passes.c:995
0x705bd3 gfc_run_passes(gfc_namespace*)
        ../../gcc/gcc/fortran/frontend-passes.c:129

> cat bug.f90
MODULE neb_utils
  INTEGER, PARAMETER :: dp=8
  TYPE neb_var_type
     REAL(KIND=dp), DIMENSION(:, :),  POINTER  :: xyz, int, wrk
  END TYPE neb_var_type
  IMPLICIT NONE
CONTAINS
  RECURSIVE SUBROUTINE get_neb_force(&
      )
    INTEGER, INTENT(IN)                      :: i
    TYPE(neb_var_type), POINTER              :: forces
    REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: dtmp1, wrk
       dtmp1       = forces%wrk(:,i)- &
    dot_product_band(neb_env,forces%wrk(:,i),tangent,Mmatrix,error)*tangent
  END SUBROUTINE get_neb_force
END MODULE neb_utils
vjo...@nanosim-s01.ethz.ch:/data/vjoost/gnu/bugs> cat bug.f90
MODULE neb_utils
  INTEGER, PARAMETER :: dp=8
  TYPE neb_var_type
     REAL(KIND=dp), DIMENSION(:, :),  POINTER  :: xyz, int, wrk
  END TYPE neb_var_type
  IMPLICIT NONE
CONTAINS
  RECURSIVE SUBROUTINE get_neb_force(&
      )
    INTEGER, INTENT(IN)                      :: i
    TYPE(neb_var_type), POINTER              :: forces
    REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: dtmp1, wrk
       dtmp1       = forces%wrk(:,i)- &
    dot_product_band(neb_env,forces%wrk(:,i),tangent,Mmatrix,error)*tangent
  END SUBROUTINE get_neb_force
END MODULE neb_utils

Reply via email to