re PR fortran/77460 (ICE when summing an overflowing array)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sun, 4 Sep 2016 18:43:40 +0000 (18:43 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sun, 4 Sep 2016 18:43:40 +0000 (18:43 +0000)
2016-09-04  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/77460
* simplify.c (simplify_transformation_to_scalar):  On error, result
may be NULL, simply return.

2016-09-04  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/77460
* gfortran.dg/pr77460.f90: New test.

From-SVN: r239979

gcc/fortran/ChangeLog
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr77460.f90 [new file with mode: 0644]

index 9913c97de04c407a092dcdaa5f6a5a684f3d367d..0b452f4664e66f0d43cc2bf8d01dca5287218788 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-04  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/77460
+       * simplify.c (simplify_transformation_to_scalar):  On error, result
+       may be NULL, simply return.
+
 2016-08-31  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/77352
index 6e6566d924548d792f09fbee0d56be2b25087bf2..c396653fa1c63baf49d2f1412d65cae0f7b080b9 100644 (file)
@@ -489,6 +489,8 @@ simplify_transformation_to_scalar (gfc_expr *result, gfc_expr *array, gfc_expr *
        }
 
       result = op (result, gfc_copy_expr (a));
+      if (!result)
+       return result;
     }
 
   return result;
index 64a7b4ade44f0065ac7f9c49982fef2e781c6a65..6f5c7878bd6f6ddf5e667cd95bc1e3e9b9c2d18c 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-04  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/77460
+       * gfortran.dg/pr77460.f90: New test.
+
 2016-09-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/65467
diff --git a/gcc/testsuite/gfortran.dg/pr77460.f90 b/gcc/testsuite/gfortran.dg/pr77460.f90
new file mode 100644 (file)
index 0000000..5e28a99
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+  double precision, parameter :: x = huge(1d0)
+  print*, sum((/x,-x/))
+  print*, sum((/x,x,-x,-x/))  ! { dg-error "overflow" }
+  print*, sum((/x,-x,1d0/))
+  print*, sum((/1d0,x,-x/))
+end