http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850
Summary: [4.6 Regression] ICE in gfc_conv_array_initializer
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: bur...@gcc.gnu.org
The following program is based on James' program at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/625faf82578e9af8
The only difference is that I replaced "(*)" by the bounds as otherwise one
cannot compile it with 4.5.
$ gfortran-4.5 test.f90 && ./a.out
SENSOR_CHANNEL = 10, 12, 17, 20, 22, 30, 33, 34
NLTE_CHANNEL = 20, 22, 34
N_NLTE_CHANNELS = 3
N_CHANNELS = 8
C_INDEX = 0, 0, 0, 1, 2, 0, 0, 3
$ gfortran-4.6 test.f90 && ./a.out
test.f90: In function ‘cindex’:
test.f90:23:0: internal compiler error: in gfc_conv_array_initializer, at
fortran/trans-array.c:4576
That's gfc_conv_array_initializer's
switch (expr->expr_type)
{
[...]
default:
gcc_unreachable ();
Where:
(gdb) p expr->expr_type
$1 = EXPR_FUNCTION
(gdb) p expr->value.function.isym->name
$4 = 0x2aaaaab42858 "unpack"
Thus, for some reason the unpack has not been simplified in 4.6.
program Cindex
implicit none
integer,parameter :: SENSOR_CHANNEL(8) = &
[10,12,17,20,22,30,33,34]
integer,parameter :: NLTE_CHANNEL(3) = [20,22,34]
integer,parameter :: N_NLTE_CHANNELS = size(NLTE_CHANNEL)
integer,parameter :: N_CHANNELS = size(SENSOR_CHANNEL)
integer i
integer,parameter :: C_INDEX(8) = unpack( &
vector = [(i,i=1,size(SENSOR_CHANNEL))], &
mask = [(any(SENSOR_CHANNEL(i) == NLTE_CHANNEL), &
i=lbound(SENSOR_CHANNEL,1),ubound(SENSOR_CHANNEL,1))], &
field = 0)
character(20) fmt
write(fmt,'(a,i0,a)') '(a,t19,',size(SENSOR_CHANNEL),'(i3:","))'
write(*,fmt) 'SENSOR_CHANNEL = ',SENSOR_CHANNEL
write(fmt,'(a,i0,a)') '(a,t19,',size(NLTE_CHANNEL),'(i3:","))'
write(*,fmt) 'NLTE_CHANNEL = ',NLTE_CHANNEL
write(*,'(a,t19,i3)') 'N_NLTE_CHANNELS = ',N_NLTE_CHANNELS
write(*,'(a,t19,i3)') 'N_CHANNELS = ',N_CHANNELS
write(fmt,'(a,i0,a)') '(a,t19,',size(C_INDEX),'(i3:","))'
write(*,fmt) 'C_INDEX = ',C_INDEX
end program Cindex