]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/84734 (Compiling codes with insane array dimensions gives an ICE after...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 10 Mar 2018 19:00:49 +0000 (19:00 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 10 Mar 2018 19:00:49 +0000 (19:00 +0000)
2018-03-10  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/84734
* arith.c (check_result, eval_intrinsic):  If result overflows, pass
the expression up the chain instead of a NULL pointer.

2018-03-10  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/84734
* gfortran.dg/pr84734.f90: New test.

From-SVN: r258419

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

index 4149ac9637a1480a5fffc3f0fc869f736100c269..840b0b0c21da48d429ab6d1d3f73dc27dcbc9276 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-10  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/84734
+       * arith.c (check_result, eval_intrinsic):  If result overflows, pass
+       the expression up the chain instead of a NULL pointer.
+
 2018-03-08 Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/64124
index e849f598df1d7ebbc895a837d073fd345fa30a47..b33ad2e80cc68b9ad002f4b1ff7fbfc62cd661ef 100644 (file)
@@ -555,10 +555,10 @@ check_result (arith rc, gfc_expr *x, gfc_expr *r, gfc_expr **rp)
       val = ARITH_OK;
     }
 
-  if (val != ARITH_OK)
-    gfc_free_expr (r);
-  else
+  if (val == ARITH_OK || val == ARITH_OVERFLOW)
     *rp = r;
+  else
+    gfc_free_expr (r);
 
   return val;
 }
@@ -1599,9 +1599,13 @@ eval_intrinsic (gfc_intrinsic_op op,
   if (rc != ARITH_OK)
     {
       gfc_error (gfc_arith_error (rc), &op1->where);
+      if (rc == ARITH_OVERFLOW)
+       goto done;
       return NULL;
     }
 
+done:
+
   gfc_free_expr (op1);
   gfc_free_expr (op2);
   return result;
index d88730fa4325a19160492919448a9cc2a4ba7669..baaf4088e38a80aa4362342f5988b8068583c8a8 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-10  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/84734
+       * gfortran.dg/pr84734.f90: New test.
+
 2018-03-10  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/pr84734.f90 b/gcc/testsuite/gfortran.dg/pr84734.f90
new file mode 100644 (file)
index 0000000..4b117ae
--- /dev/null
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! PR fortran/84734
+   integer :: b(huge(1_8)+1_8) = 0 ! { dg-error "Arithmetic overflow" }
+   end