The following code (original code courtesy of Mike Zingale, reduced by yours
truly) gives an ICE with current mainline:
module box_module
type box
integer :: m = 0
end type box
end module box_module
module sort_box_module
contains
subroutine heapsort_box(cmp)
interface
subroutine cmp(a)
use box_module
type(box) :: a
end subroutine cmp
end interface
optional :: cmp
end subroutine heapsort_box
end module sort_box_module
module boxarray_module
use box_module
implicit none
type boxarray
type(box), allocatable :: bxs(:)
end type boxarray
contains
subroutine boxarray_build_l(ba)
type(boxarray) :: ba
allocate(ba%bxs(1))
end subroutine boxarray_build_l
subroutine boxarray_sort()
use sort_box_module
call heapsort_box
end subroutine boxarray_sort
end module boxarray_module
The ICE is:
boxarray.f90: In function boxarray_build_l:
boxarray.f90:34: internal compiler error: in fold_convert, at fold-const.c:2330
And its backtrace is:
Breakpoint 1, fold_convert (type=0xb7c2dbd0, arg=0xb7c2f33c)
at ../../../trunk/gcc/fold-const.c:2330
2330 gcc_unreachable ();
(gdb) where
#0 fold_convert (type=0xb7c2dbd0, arg=0xb7c2f33c)
at ../../../trunk/gcc/fold-const.c:2330
#1 0x080c8e25 in gfc_trans_scalar_assign (lse=0xbfb26f64, rse=0xbfb26f3c, ts=
{type = BT_DERIVED, kind = 0, derived = 0x88b79d0, cl = 0x0},
l_is_temp=1 '\001', r_is_var=0 '\0')
at ../../../trunk/gcc/fortran/trans-expr.c:3438
#2 0x080cda79 in gfc_trans_assignment_1 (expr1=0x88ce5d0, expr2=0x88cf018,
init_flag=1 '\001') at ../../../trunk/gcc/fortran/trans-expr.c:3833
#3 0x080cdd45 in gfc_trans_assignment (expr1=0x88ce5d0, expr2=0x88cf018,
init_flag=96 '`') at ../../../trunk/gcc/fortran/trans-expr.c:3973
#4 0x080ce911 in gfc_trans_init_assign (code=0x88cead8)
at ../../../trunk/gcc/fortran/trans-expr.c:3979
#5 0x080b0226 in gfc_trans_code (code=0x88cead8)
at ../../../trunk/gcc/fortran/trans.c:485
#6 0x080c6045 in gfc_generate_function_code (ns=0x88d0420)
at ../../../trunk/gcc/fortran/trans-decl.c:3217
#7 0x080af648 in gfc_generate_module_code (ns=0x887d7a0)
at ../../../trunk/gcc/fortran/trans.c:693
#8 0x0808b9e5 in gfc_parse_file () at ../../../trunk/gcc/fortran/parse.c:3256
#9 0x080ab10d in gfc_be_parse_file (set_yydebug=0)
at ../../../trunk/gcc/fortran/f95-lang.c:305
#10 0x082f4db2 in toplev_main (argc=13, argv=0xbfb27284)
at ../../../trunk/gcc/toplev.c:1050
#11 0x080ecf3f in main (argc=15, argv=0x0) at ../../../trunk/gcc/main.c:35
I couldn't reduce it further, I think the ICE needs the optional argument to
heapsort_box and the default initialization in type box.
--
Summary: ICE on nasty derived types code
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31630