Am 02.01.2018 um 19:00 schrieb Thomas Koenig:
Hello world,
I have committed the patch below as obvious to fix the
same bug on gcc-7 that my recent patch fixed on trunk.
... of course, better with a patch which includes
the changes instead of the ChangeLog entries:
Index: fortran/simplify.c
===================================================================
--- fortran/simplify.c (Revision 256009)
+++ fortran/simplify.c (Arbeitskopie)
@@ -1991,7 +1991,9 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *sh
mpz_clear (size);
/* Adjust shft to deal with right or left shifts. */
- shft = shft < 0 ? 1 - shft : shft;
+ shft = shft % sz;
+ if (shft < 0)
+ shft += sz;
/* Special case: Shift to the original order! */
if (sz == 0 || shft % sz == 0)
Index: testsuite/gfortran.dg/simplify_cshift_1.f90
===================================================================
--- testsuite/gfortran.dg/simplify_cshift_1.f90 (Revision 256009)
+++ testsuite/gfortran.dg/simplify_cshift_1.f90 (Arbeitskopie)
@@ -23,12 +23,12 @@ program foo
v = cshift(c, 2)
if (any(b /= v)) call abort
- ! Special cases shift = 0, size(a), 1-size(a)
+ ! Special cases shift = 0, size(a), size(a)
b = cshift([1, 2, 3, 4, 5], 0)
if (any(b /= a)) call abort
b = cshift([1, 2, 3, 4, 5], size(a))
if (any(b /= a)) call abort
- b = cshift([1, 2, 3, 4, 5], 1-size(a))
+ b = cshift([1, 2, 3, 4, 5], -size(a))
if (any(b /= a)) call abort
! simplification of array arg.