Committed to 6-branch and trunk.

2016-10-11  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/77942
        * simplify.c (gfc_simplify_cshift): Check for zero.

2016-10-11  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/77942
        * gfortran.dg/pr77942.f90


Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c      (revision 241006)
+++ gcc/fortran/simplify.c      (working copy)
@@ -1989,7 +1989,7 @@ gfc_simplify_cshift (gfc_expr *array, gf
       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);
Index: gcc/testsuite/gfortran.dg/pr77942.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr77942.f90       (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr77942.f90       (working copy)
@@ -0,0 +1,5 @@
+! { dg-do compile }
+program p
+   character, parameter :: c(2) = 'a'
+   print *, cshift(c(2:1), 1)
+end

-- 
Steve

Reply via email to