diff mbox series

[committed] Fix PR 84640

Message ID 35b62772-6063-5df5-5e5c-6ecce948312b@netcologne.de
State New
Headers show
Series [committed] Fix PR 84640 | expand

Commit Message

Thomas Koenig Oct. 6, 2018, 11:47 a.m. UTC
Hi,

I just committed the fix below as obvious and simple. No test case
because the problem was only visible in with an instrumented
compiler.

Regards

	Thomas

  2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/84640
	* simplify.c (gfc_simplify_cshift): Extend size of hs_ex and ss_ex
	by one. Set extents one past the array boundaries to zero to avoid
	warning with instrumented compiler.
	(gfc_simplify_eoshift): Likewise, only for ss_ex.
diff mbox series

Patch

Index: simplify.c
===================================================================
--- simplify.c	(Revision 264897)
+++ simplify.c	(Arbeitskopie)
@@ -2011,11 +2011,11 @@  gfc_simplify_cshift (gfc_expr *array, gfc_expr *sh
   ssize_t *shiftvec, *hptr;
   ssize_t shift_val, len;
   ssize_t count[GFC_MAX_DIMENSIONS], extent[GFC_MAX_DIMENSIONS],
-    hs_ex[GFC_MAX_DIMENSIONS],
+    hs_ex[GFC_MAX_DIMENSIONS + 1],
     hstride[GFC_MAX_DIMENSIONS], sstride[GFC_MAX_DIMENSIONS],
     a_extent[GFC_MAX_DIMENSIONS], a_stride[GFC_MAX_DIMENSIONS],
     h_extent[GFC_MAX_DIMENSIONS],
-    ss_ex[GFC_MAX_DIMENSIONS];
+    ss_ex[GFC_MAX_DIMENSIONS + 1];
   ssize_t rsoffset;
   int d, n;
   bool continue_loop;
@@ -2110,6 +2110,8 @@  gfc_simplify_cshift (gfc_expr *array, gfc_expr *sh
 	  n++;
 	}
     }
+  ss_ex[n] = 0;
+  hs_ex[n] = 0;
 
   if (shiftvec)
     {
@@ -2403,7 +2405,7 @@  gfc_simplify_eoshift (gfc_expr *array, gfc_expr *s
   ssize_t shift_val, len;
   ssize_t count[GFC_MAX_DIMENSIONS], extent[GFC_MAX_DIMENSIONS],
     sstride[GFC_MAX_DIMENSIONS], a_extent[GFC_MAX_DIMENSIONS],
-    a_stride[GFC_MAX_DIMENSIONS], ss_ex[GFC_MAX_DIMENSIONS];
+    a_stride[GFC_MAX_DIMENSIONS], ss_ex[GFC_MAX_DIMENSIONS + 1];
   ssize_t rsoffset;
   int d, n;
   bool continue_loop;
@@ -2546,6 +2548,7 @@  gfc_simplify_eoshift (gfc_expr *array, gfc_expr *s
 	  n++;
 	}
     }
+  ss_ex[n] = 0;
 
   continue_loop = true;
   d = array->rank;