print *, f() contains function f() integer :: f(iargc()*10) end end ICE's with gcc version 5.3.1 20160412 print *, f() 1 internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugs.opensuse.org/> for instructions. Also ICE's with nint(rand()), irand(), nint(second()). It does not crash with itime() and nint(secnd()).
Confirmed on trunk. > ./f951 -quiet t.f90 t.f90:1:0: print *, f() internal compiler error: Segmentation fault 0xf03530 crash_signal /space/rguenther/src/svn/trunk/gcc/toplev.c:333 0x8cd83c gfc_apply_interface_mapping_to_expr /space/rguenther/src/svn/trunk/gcc/fortran/trans-expr.c:4255 0x8cd7b6 gfc_apply_interface_mapping_to_expr /space/rguenther/src/svn/trunk/gcc/fortran/trans-expr.c:4245 0x8cd969 gfc_apply_interface_mapping(gfc_interface_mapping*, gfc_se*, gfc_expr*) /space/rguenther/src/svn/trunk/gcc/fortran/trans-expr.c:4291 0x887f92 gfc_set_loop_bounds_from_array_spec(gfc_interface_mapping*, gfc_se*, gfc_array_spec*) ...
The following obvious(?) patch appears to fix the ICE: Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (revision 258112) +++ gcc/fortran/trans-expr.c (working copy) @@ -4349,6 +4349,8 @@ if (expr->value.function.esym == NULL && expr->value.function.isym != NULL + && expr->value.function.actual + && expr->value.function.actual->expr && expr->value.function.actual->expr->symtree && gfc_map_intrinsic_function (expr, mapping)) break;
Patch submitted: https://gcc.gnu.org/ml/fortran/2018-03/msg00009.html
Author: kargl Date: Sun Mar 4 01:37:13 2018 New Revision: 258228 URL: https://gcc.gnu.org/viewcvs?rev=258228&root=gcc&view=rev Log: 2018-03-03 Harald Anlauf <anlauf@gmx.de> PR fortran/71085 * trans-expr.c (gfc_apply_interface_mapping_to_expr): Do not dereference NULL pointer. 2018-03-03 Harald Anlauf <anlauf@gmx.de> PR fortran/71085 * gfortran.dg/pr71085.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pr71085.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c trunk/gcc/testsuite/ChangeLog
Author: kargl Date: Sun Mar 4 01:52:24 2018 New Revision: 258229 URL: https://gcc.gnu.org/viewcvs?rev=258229&root=gcc&view=rev Log: 2018-03-03 Harald Anlauf <anlauf@gmx.de> PR fortran/71085 * trans-expr.c (gfc_apply_interface_mapping_to_expr): Do not dereference NULL pointer. 2018-03-03 Harald Anlauf <anlauf@gmx.de> PR fortran/71085 * gfortran.dg/pr71085.f90: New test. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr71085.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/trans-expr.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
Author: kargl Date: Sun Mar 4 05:11:31 2018 New Revision: 258230 URL: https://gcc.gnu.org/viewcvs?rev=258230&root=gcc&view=rev Log: 2018-03-03 Harald Anlauf <anlauf@gmx.de> PR fortran/71085 * trans-expr.c (gfc_apply_interface_mapping_to_expr): Do not dereference NULL pointer. 2018-03-03 Harald Anlauf <anlauf@gmx.de> PR fortran/71085 * gfortran.dg/pr71085.f90: New test. Added: branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr71085.f90 Modified: branches/gcc-6-branch/gcc/fortran/ChangeLog branches/gcc-6-branch/gcc/fortran/trans-expr.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed on 6-branch, 7-branch, and trunk. Thanks for bug report.