public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-9648] PR fortran/99840 - ICE in gfc_simplify_matmul, at fortran/simplify.c:4777
@ 2021-04-01  6:15 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-04-01  6:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:591b5c903f8d3fc73caa403038cbd680b367f23b

commit r10-9648-g591b5c903f8d3fc73caa403038cbd680b367f23b
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Apr 1 07:49:32 2021 +0200

    PR fortran/99840 - ICE in gfc_simplify_matmul, at fortran/simplify.c:4777
    
    The simplification of the transposition of a constant array shall properly
    initialize and set the shape of the result.
    
    gcc/fortran/ChangeLog:
    
            PR fortran/99840
            * simplify.c (gfc_simplify_transpose): Properly initialize
            resulting shape.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/99840
            * gfortran.dg/transpose_5.f90: New test.
    
    (cherry picked from commit d7cef070bf43bfb3f3d77bac42eadea06c4b0281)

Diff:
---
 gcc/fortran/simplify.c                    | 4 ++--
 gcc/testsuite/gfortran.dg/transpose_5.f90 | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 5325b4122fa..d28aa7a3c16 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -8075,8 +8075,8 @@ gfc_simplify_transpose (gfc_expr *matrix)
 			       &matrix->where);
   result->rank = 2;
   result->shape = gfc_get_shape (result->rank);
-  mpz_set (result->shape[0], matrix->shape[1]);
-  mpz_set (result->shape[1], matrix->shape[0]);
+  mpz_init_set (result->shape[0], matrix->shape[1]);
+  mpz_init_set (result->shape[1], matrix->shape[0]);
 
   if (matrix->ts.type == BT_CHARACTER)
     result->ts.u.cl = matrix->ts.u.cl;
diff --git a/gcc/testsuite/gfortran.dg/transpose_5.f90 b/gcc/testsuite/gfortran.dg/transpose_5.f90
new file mode 100644
index 00000000000..ed4b643acbf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/transpose_5.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "-O2" }
+! PR fortran/99840 - ICE in gfc_simplify_matmul, at fortran/simplify.c:4777
+program p
+  integer, parameter :: x(0,0) = 0
+  integer :: y(0,0)
+  y = matmul (x, transpose(x))
+end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-01  6:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01  6:15 [gcc r10-9648] PR fortran/99840 - ICE in gfc_simplify_matmul, at fortran/simplify.c:4777 Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).