I've committed the following patch that fixes a regression
for simplification of cshift when the array is zero sized.
Commits were made to both the 6-branch and 7-branch.  The
regression does not occur on trunk.

2018-01-04  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR Fortran/83679
        * simplify.c (gfc_simplify_cshift): Restore early return for zero-sized
        array.  Update Copyright year while here.

Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c      (revision 256260)
+++ gcc/fortran/simplify.c      (working copy)
@@ -1990,13 +1990,17 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift,
       sz = mpz_get_si (size);
       mpz_clear (size);
 
+      /* Special case: Zero-sized array.  */
+      if (sz == 0)
+       return a;
+
       /* Adjust shft to deal with right or left shifts. */
       shft = shft % sz;
       if (shft < 0)
        shft += sz;
 
       /* Special case: Shift to the original order!  */
-      if (sz == 0 || shft % sz == 0)
+      if (shft % sz == 0)
        return a;
 
       result = gfc_copy_expr (a);

-- 
Steve

Reply via email to