https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77460
Bug ID: 77460 Summary: ICE when summing an overflowing array Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: kargl at gcc dot gnu.org Target Milestone: --- See in c.l.f. double precision, parameter :: x = huge(1d0) print*, sum((/x,-x/)) print*, sum((/x,x,-x,-x/)) print*, sum((/x,-x,1d0/)) print*, sum((/1d0,x,-x/)) end With gfortran 4.6.3 I get: print*, sum((/x,x,-x,-x/)) 1 Error: Arithmetic overflow at (1) f951: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions. I have a patch Index: simplify.c =================================================================== --- simplify.c (revision 239797) +++ simplify.c (working copy) @@ -489,6 +489,8 @@ simplify_transformation_to_scalar (gfc_e } result = op (result, gfc_copy_expr (a)); + if (!result) + return result; } return result;