Changed between 20200517 and 20200524 : $ cat z1.f90 module m type t character(((0)/0)) :: c end type end $ gfortran-11-20200517 -c z1.f90 z1.f90:3:22: 3 | character(((0)/0)) :: c | 1 Error: Division by zero at (1) $ gfortran-11-20200621 -c z1.f90 f951: internal compiler error: in gfc_get_derived_type, at fortran/trans-types.c:2729 0x784843 gfc_get_derived_type(gfc_symbol*, int) ../../gcc/fortran/trans-types.c:2729 0x784b68 gfc_typenode_for_spec(gfc_typespec*, int) ../../gcc/fortran/trans-types.c:1166 0x784dbe gfc_sym_type(gfc_symbol*) ../../gcc/fortran/trans-types.c:2247 0x729616 gfc_get_symbol_decl(gfc_symbol*) ../../gcc/fortran/trans-decl.c:1769 0x72c888 gfc_create_module_variable ../../gcc/fortran/trans-decl.c:5302 0x6ebde2 do_traverse_symtree ../../gcc/fortran/symbol.c:4162 0x72d08b gfc_generate_module_vars(gfc_namespace*) ../../gcc/fortran/trans-decl.c:5801 0x707ca4 gfc_generate_module_code(gfc_namespace*) ../../gcc/fortran/trans.c:2238 0x6b4b01 translate_all_program_units ../../gcc/fortran/parse.c:6294 0x6b4b01 gfc_parse_file() ../../gcc/fortran/parse.c:6546 0x70098f gfc_be_parse_file ../../gcc/fortran/f95-lang.c:212
Related, with different backtraces : $ cat z2.f90 module m character(((0)/0)) :: c = '123456789' end $ cat z3.f90 subroutine s(c) character(((0)/0)) :: c end $ cat z4.f90 program p character(((0)/0)) :: c common /x/ c end $ cat z5.f90 program p character(((0)/0)) :: c = '123456789' common c end
Started with r11-461-ge5abd1cb91606197.
The master branch has been updated by Mark Eggleston <markeggleston@gcc.gnu.org>: https://gcc.gnu.org/g:c336eda750d4e7a0827fedf995da955d6d88d5ca commit r11-2907-gc336eda750d4e7a0827fedf995da955d6d88d5ca Author: Mark Eggleston <markeggleston@gcc.gnu.org> Date: Fri Aug 21 06:39:30 2020 +0100 Fortran : ICE for division by zero in declaration PR95882 A length expression containing a divide by zero in a character declaration will result in an ICE if the constant is anymore complicated that a contant divided by a constant. The cause was that char_len_param_value can return MATCH_YES even if a divide by zero was seen. Prior to returning check whether a divide by zero was seen and if so set it to MATCH_ERROR. 2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran PR fortran/95882 * decl.c (char_len_param_value): Check gfc_seen_div0 and if it is set return MATCH_ERROR. 2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95882 * gfortran.dg/pr95882_1.f90: New test. * gfortran.dg/pr95882_2.f90: New test. * gfortran.dg/pr95882_3.f90: New test. * gfortran.dg/pr95882_4.f90: New test. * gfortran.dg/pr95882_5.f90: New test.
The releases/gcc-10 branch has been updated by Mark Eggleston <markeggleston@gcc.gnu.org>: https://gcc.gnu.org/g:8323d09e82345a1ca39f6630cdd22ccf4ef38a84 commit r10-8679-g8323d09e82345a1ca39f6630cdd22ccf4ef38a84 Author: Mark Eggleston <markeggleston@gcc.gnu.org> Date: Fri Aug 21 06:39:30 2020 +0100 Fortran : ICE for division by zero in declaration PR95882 A length expression containing a divide by zero in a character declaration will result in an ICE if the constant is anymore complicated that a contant divided by a constant. The cause was that char_len_param_value can return MATCH_YES even if a divide by zero was seen. Prior to returning check whether a divide by zero was seen and if so set it to MATCH_ERROR. 2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran PR fortran/95882 * decl.c (char_len_param_value): Check gfc_seen_div0 and if it is set return MATCH_ERROR. 2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95882 * gfortran.dg/pr95882_1.f90: New test. * gfortran.dg/pr95882_2.f90: New test. * gfortran.dg/pr95882_3.f90: New test. * gfortran.dg/pr95882_4.f90: New test. * gfortran.dg/pr95882_5.f90: New test. (cherry picked from commit c336eda750d4e7a0827fedf995da955d6d88d5ca)
The releases/gcc-9 branch has been updated by Mark Eggleston <markeggleston@gcc.gnu.org>: https://gcc.gnu.org/g:042c58a4b8ba48fdf26c9003154e9d3b83d4c568 commit r9-8836-g042c58a4b8ba48fdf26c9003154e9d3b83d4c568 Author: Mark Eggleston <markeggleston@gcc.gnu.org> Date: Fri Aug 21 06:39:30 2020 +0100 Fortran : ICE for division by zero in declaration PR95882 A length expression containing a divide by zero in a character declaration will result in an ICE if the constant is anymore complicated that a contant divided by a constant. The cause was that char_len_param_value can return MATCH_YES even if a divide by zero was seen. Prior to returning check whether a divide by zero was seen and if so set it to MATCH_ERROR. 2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran PR fortran/95882 * decl.c (char_len_param_value): Check gfc_seen_div0 and if it is set return MATCH_ERROR. 2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95882 * gfortran.dg/pr95882_1.f90: New test. * gfortran.dg/pr95882_2.f90: New test. * gfortran.dg/pr95882_3.f90: New test. * gfortran.dg/pr95882_4.f90: New test. * gfortran.dg/pr95882_5.f90: New test. (cherry picked from commit c336eda750d4e7a0827fedf995da955d6d88d5ca)
committed and backported.