http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470
Bug ID: 58470 Summary: ICE on invalid with FINAL function and type extension Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: abensonca at gmail dot com The following causes an ICE with gfortran 4.9.0 (r202667): module cf type :: cfml contains final :: mld end type cfml type, extends(cfml) :: cfmde end type cfmde contains subroutine mld(s) class(cfml), intent(inout) :: s end subroutine mld end module cf $ gfortran -v Using built-in specs. COLLECT_GCC=/opt/gcc-trunk/bin/gfortran COLLECT_LTO_WRAPPER=/opt/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/opt/gcc-trunk --enable-languages=c,c++,fortran --disable-multilib Thread model: posix gcc version 4.9.0 20130917 (experimental) (GCC) $ gfortran -c bug.F90 -o bug.o bug.F90: In function ‘__final_cf_Cfml’: bug.F90:12:0: internal compiler error: Segmentation fault end module cf ^ 0x99112f crash_signal ../../gcc-trunk/gcc/toplev.c:335 0x5f8e0c gfc_conv_derived_to_class(gfc_se*, gfc_expr*, gfc_typespec, tree_node*, bool, bool) ../../gcc-trunk/gcc/fortran/trans-expr.c:424 0x5f1140 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*, gfc_expr*, vec<tree_node*, va_gc, vl_embed>*) ../../gcc-trunk/gcc/fortran/trans-expr.c:4028 0x61cd04 gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool) ../../gcc-trunk/gcc/fortran/trans-stmt.c:406 0x5bf010 trans_code ../../gcc-trunk/gcc/fortran/trans.c:1700 0x621a40 gfc_trans_integer_select ../../gcc-trunk/gcc/fortran/trans-stmt.c:1990 0x621a40 gfc_trans_select(gfc_code*) ../../gcc-trunk/gcc/fortran/trans-stmt.c:2484 0x5bed77 trans_code ../../gcc-trunk/gcc/fortran/trans.c:1743 0x5e7dae gfc_generate_function_code(gfc_namespace*) ../../gcc-trunk/gcc/fortran/trans-decl.c:5528 0x5c0781 gfc_generate_module_code(gfc_namespace*) ../../gcc-trunk/gcc/fortran/trans.c:1955 0x57eee7 translate_all_program_units ../../gcc-trunk/gcc/fortran/parse.c:4496 0x57eee7 gfc_parse_file() ../../gcc-trunk/gcc/fortran/parse.c:4706 0x5baab5 gfc_be_parse_file ../../gcc-trunk/gcc/fortran/f95-lang.c:189 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. The code is invalid because the finalization subroutine defines its argument as CLASS rather than TYPE. Removing the "cfmde" type (or removing the ", extends(cfml)") results in the correct error message: $ gfortran -c bug.F90 -o bug.o bug.F90:9.18: subroutine mld(s) 1 Error: Argument of FINAL procedure at (1) must be of type 'cfml'