* [PATCH] PR fortran/99840 - [8/9/10/11 Regression] ICE in gfc_simplify_matmul, at fortran/simplify.c:4777
@ 2021-03-31 21:08 Harald Anlauf
2021-04-01 0:28 ` Jerry DeLisle
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2021-03-31 21:08 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
Dear all,
the simplification of the TRANSPOSE of a zero-sized array would lead to
an ICE if the result was used in a subsequent simplification of a MATMUL.
The reason was the lack of the proper initialization of the shape, which
is mpz_t. Use mpz_init_set instead of mpz_set.
Regtested on x86_64-pc-linux-gnu. OK for mainline?
Since this is a regression, backport to all affected branches?
Thanks,
Harald
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr99840.patch --]
[-- Type: text/x-patch, Size: 1092 bytes --]
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 388aca7c38c..c27b47aa98f 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -8123,8 +8123,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..682b1c8552b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/transpose_5.f90
@@ -0,0 +1,8 @@
+! { dg-do compiler }
+! { 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] 2+ messages in thread
* Re: [PATCH] PR fortran/99840 - [8/9/10/11 Regression] ICE in gfc_simplify_matmul, at fortran/simplify.c:4777
2021-03-31 21:08 [PATCH] PR fortran/99840 - [8/9/10/11 Regression] ICE in gfc_simplify_matmul, at fortran/simplify.c:4777 Harald Anlauf
@ 2021-04-01 0:28 ` Jerry DeLisle
0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2021-04-01 0:28 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
Yes OK for trunk and affected branches.
Thanks,
Jerry
On 3/31/21 2:08 PM, Harald Anlauf via Fortran wrote:
> Dear all,
>
> the simplification of the TRANSPOSE of a zero-sized array would lead to
> an ICE if the result was used in a subsequent simplification of a MATMUL.
> The reason was the lack of the proper initialization of the shape, which
> is mpz_t. Use mpz_init_set instead of mpz_set.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
> Since this is a regression, backport to all affected branches?
>
> Thanks,
> Harald
>
>
> 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.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-01 0:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 21:08 [PATCH] PR fortran/99840 - [8/9/10/11 Regression] ICE in gfc_simplify_matmul, at fortran/simplify.c:4777 Harald Anlauf
2021-04-01 0:28 ` Jerry DeLisle
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).