Internal compiler error with sum intrinsic

This might be related to TPR#4256, as the program is similar. The following code:

program mult
  implicit none
  integer, parameter :: m = 6, n = 23
  integer, dimension(m), parameter :: b = (/ 3, 4, 2, 2, 6, 6 /)
  integer, dimension(n) :: a1 = (/1,4,7,2,6,9,8,5,2,5,1,6,3,6,4,7,8,4,0,4,3,2,7/)
  integer, dimension(n) :: a2 = (/5,1,2,3,4,8,7,9,6,5,2,3,4,5,9,8,2,3,4,3,1,0,3/)
  integer, dimension(m) :: d
  integer :: j
  do j = 1, m
     d(j) = sum(a1(sum(b(:j-1))+1:sum(b(:j)))  &
          * a2(sum(b(:j-1))+1:sum(b(:j))))
  end do
  write (*, "(9i4)") d
end program mult

gives an internal compiler error. Specifically,

% pgf95 -o mult mult.f90
PGF90-S-0000-Internal compiler error. transform_call:Array Expression can't be here      55 (mult.f90: 10)
Lowering Error: bad ast optype in expression [ast=37,asttype=12,datatype=0]
Lowering Error: unknown intrinsic function [ast=40,asttype=14,datatype=6]
Lowering Error: bad ast optype in expression [ast=42,asttype=12,datatype=0]
Lowering Error: unknown intrinsic function [ast=45,asttype=14,datatype=6]
Lowering Error: bad ast optype in expression [ast=46,asttype=12,datatype=0]
Lowering Error: unknown intrinsic function [ast=49,asttype=14,datatype=6]
Lowering Error: unknown intrinsic function [ast=52,asttype=14,datatype=6]
Lowering Error: bad ast optype in expression [ast=53,asttype=12,datatype=0]
PGF90-F-0000-Internal compiler error. Errors in Lowering       8 (mult.f90: 14)
PGF90/any Linux/x86-64 6.2-3: compilation aborted

However, this program works fine:

program mult2
  implicit none
  integer, parameter :: m = 6, n = 23
  integer, dimension(m), parameter :: b = (/ 3, 4, 2, 2, 6, 6 /)
  integer, dimension(n) :: a1 = (/1,4,7,2,6,9,8,5,2,5,1,6,3,6,4,7,8,4,0,4,3,2,7/)
  integer, dimension(n) :: a2 = (/5,1,2,3,4,8,7,9,6,5,2,3,4,5,9,8,2,3,4,3,1,0,3/)
  integer, dimension(m) :: d
  integer :: j, lb, ub
  do j = 1, m
     lb = sum(b(:j-1)) + 1
     ub = sum(b(:j))
     d(j) = sum(a1(lb:ub) * a2(lb:ub))
  end do
  write (*, "(9i4)") d
end program mult2

with output of:

  23 158  57  27 168  48

The second program is probably better in terms of clarity, but it seems like the first program should work as well.

Looks like this one has been fixed as of 7.0.

% pgf90 -c uf979.f90 -V6.2-5
PGF90-S-0000-Internal compiler error. transform_call:Array Expression can't be here      55 (uf979.f90: 10)
Lowering Error: bad ast optype in expression [ast=37,asttype=12,datatype=0]
Lowering Error: unknown intrinsic function [ast=40,asttype=14,datatype=6]
Lowering Error: bad ast optype in expression [ast=42,asttype=12,datatype=0]
Lowering Error: unknown intrinsic function [ast=45,asttype=14,datatype=6]
Lowering Error: bad ast optype in expression [ast=46,asttype=12,datatype=0]
Lowering Error: unknown intrinsic function [ast=49,asttype=14,datatype=6]
Lowering Error: unknown intrinsic function [ast=52,asttype=14,datatype=6]
Lowering Error: bad ast optype in expression [ast=53,asttype=12,datatype=0]
PGF90-F-0000-Internal compiler error. Errors in Lowering       8 (uf979.f90: 14)
PGF90/any Linux/x86-64 6.2-5: compilation aborted
%
% pgf90 -o uf979.out uf979.f90 -V7.0-6
% uf979.out
  23 158  57  27 168  48