From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 498A8384B823; Wed, 31 Mar 2021 20:38:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 498A8384B823 From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99840] [9/10/11 Regression] ICE in gfc_simplify_matmul, at fortran/simplify.c:4777 Date: Wed, 31 Mar 2021 20:38:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Mar 2021 20:38:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99840 --- Comment #4 from anlauf at gcc dot gnu.org --- For reasons I do not understand, Breakpoint 1, gfc_simplify_matmul (matrix_a=3D0x292bbf0, matrix_b=3D0x292c5= 50) at ../../gcc-trunk/gcc/fortran/simplify.c:4777 4777 result_columns =3D mpz_get_si (matrix_b->shape[1]); (gdb) p matrix_b->shape[1]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 $64 =3D {{_mp_alloc =3D 0, _mp_size =3D 0, _mp_d =3D 0x0}} (gdb) p matrix_b->shape[0] $65 =3D {{_mp_alloc =3D 0, _mp_size =3D 0, _mp_d =3D 0x0}} This is a result from the mpz_set in gfc_simplify_transpose. Isn't this a representation of zero? Alternative patch, which passes the relevant regtesting: diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 388aca7c38c..b884a81fce0 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -8123,16 +8123,16 @@ gfc_simplify_transpose (gfc_expr *matrix) &matrix->where); result->rank =3D 2; result->shape =3D gfc_get_shape (result->rank); - mpz_set (result->shape[0], matrix->shape[1]); - mpz_set (result->shape[1], matrix->shape[0]); + matrix_rows =3D mpz_get_si (matrix->shape[0]); + matrix_cols =3D mpz_get_si (matrix->shape[1]); + mpz_init_set_si (result->shape[0], matrix_cols); + mpz_init_set_si (result->shape[1], matrix_rows); if (matrix->ts.type =3D=3D BT_CHARACTER) result->ts.u.cl =3D matrix->ts.u.cl; else if (matrix->ts.type =3D=3D BT_DERIVED) result->ts.u.derived =3D matrix->ts.u.derived; - matrix_rows =3D mpz_get_si (matrix->shape[0]); - matrix_cols =3D mpz_get_si (matrix->shape[1]); for (row =3D 0; row < matrix_rows; ++row) for (col =3D 0; col < matrix_cols; ++col) {=