[Committed] PR fortran/104999 - [12 Regression] runtime error: pointer index expression with base 0x00000cf67720 overflowed to 0xffffffffea627728

Message ID trinity-f2a19b3d-8f6e-452b-9cb8-f987d8422fef-1647979505136@3c-app-gmx-bap14
State Committed
Headers
Series [Committed] PR fortran/104999 - [12 Regression] runtime error: pointer index expression with base 0x00000cf67720 overflowed to 0xffffffffea627728 |

Commit Message

Harald Anlauf March 22, 2022, 8:05 p.m. UTC
  Dear all,

as reported by Martin Liška, a sanitized compiler hits an uninitialized stride
value when simplifying CSHIFT in testcase gfortran.dg/simplify_cshift_1.f90.
Committed as obvious after confirmation in the PR by Martin that the attached
patch fixes the issue.

commit r12-7771-g774ab2edcb5f3a24ed3a5cffd1143bd49a69f1ee

Thanks,
Harald
  

Patch

From 774ab2edcb5f3a24ed3a5cffd1143bd49a69f1ee Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Tue, 22 Mar 2022 20:54:18 +0100
Subject: [PATCH] Fortran: ensure intialization of stride array

gcc/fortran/ChangeLog:

	PR fortran/104999
	* simplify.cc (gfc_simplify_cshift): Ensure temporary holding
	source array stride is initialized.
---
 gcc/fortran/simplify.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 0c15bcb2b0a..233cc42137f 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -2134,6 +2134,7 @@  gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim)

   resultvec = XCNEWVEC (gfc_expr *, arraysize);

+  sstride[0] = 0;
   extent[0] = 1;
   count[0] = 0;

--
2.34.1