From f6cf4810e942f05e2cc3afe2513001af53ffa1dd Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 11 Oct 2016 21:03:04 +0000 Subject: [PATCH] re PR fortran/77942 (ICE: Floating point exception, in gfc_simplify_cshift, at fortran/simplify.c:1845) 2016-10-11 Steven G. Kargl PR fortran/77942 * simplify.c (gfc_simplify_cshift): Check for zero. 2016-10-11 Steven G. Kargl PR fortran/77942 * gfortran.dg/pr77942.f90 From-SVN: r241008 --- gcc/fortran/ChangeLog | 7 ++++++- gcc/fortran/simplify.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr77942.f90 | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr77942.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e9b88686c48..15105753ed5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-10-11 Steven G. Kargl + + PR fortran/77942 + * simplify.c (gfc_simplify_cshift): Check for zero. + 2016-10-11 Fritz Reese * iresolve.c (get_radians, get_degrees): Fix sloppy commit. @@ -5,7 +10,7 @@ 2016-10-11 Jerry DeLisle - * simplify.c (radians_f): Fix mpdr_mod. + * simplify.c (radians_f): Fix mpfr_mod. * ireolce.c (get_degrees): Declare tmp. 2016-10-11 Fritz Reese diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index eb6e41258fb..b593bce1f4a 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1989,7 +1989,7 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim) shft = shft < 0 ? 1 - shft : shft; /* Special case: Shift to the original order! */ - if (shft % sz == 0) + if (sz == 0 || shft % sz == 0) return a; result = gfc_copy_expr (a); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e1ed8e5250f..1c574b9189e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-11 Steven G. Kargl + + PR fortran/77942 + * gfortran.dg/pr77942.f90 + 2016-10-11 Fritz Reese * gfortran.dg/dec_math.f90: New testsuite. diff --git a/gcc/testsuite/gfortran.dg/pr77942.f90 b/gcc/testsuite/gfortran.dg/pr77942.f90 new file mode 100644 index 00000000000..7d46afbd41c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77942.f90 @@ -0,0 +1,5 @@ +! { dg-do compile } +program p + character, parameter :: c(2) = 'a' + print *, cshift(c(2:1), 1) +end