[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-11-13 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-12, and on 11- and 10-branch.  Closing.

Thanks for the report!

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-11-13 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

--- Comment #9 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:4b99f0c90f272c5cd94af20f15b95ba702fa0aa6

commit r10-10268-g4b99f0c90f272c5cd94af20f15b95ba702fa0aa6
Author: Harald Anlauf 
Date:   Fri Nov 5 23:48:20 2021 +0100

Fortran: fix simplification of array-valued parameter expressions

gcc/fortran/ChangeLog:

PR fortran/102817
* expr.c (simplify_parameter_variable): Copy shape of referenced
subobject when simplifying.

gcc/testsuite/ChangeLog:

PR fortran/102817
* gfortran.dg/pr102817.f90: New test.

(cherry picked from commit bcf3728abe842922005166d3065fc5fdfea1)

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-11-07 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

--- Comment #8 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:907fd5049735ed1bd17e221db5a812dedee5dfc8

commit r11-9214-g907fd5049735ed1bd17e221db5a812dedee5dfc8
Author: Harald Anlauf 
Date:   Fri Nov 5 23:48:20 2021 +0100

Fortran: fix simplification of array-valued parameter expressions

gcc/fortran/ChangeLog:

PR fortran/102817
* expr.c (simplify_parameter_variable): Copy shape of referenced
subobject when simplifying.

gcc/testsuite/ChangeLog:

PR fortran/102817
* gfortran.dg/pr102817.f90: New test.

(cherry picked from commit bcf3728abe842922005166d3065fc5fdfea1)

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-11-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:bcf3728abe842922005166d3065fc5fdfea1

commit r12-4967-gbcf3728abe842922005166d3065fc5fdfea1
Author: Harald Anlauf 
Date:   Fri Nov 5 23:48:20 2021 +0100

Fortran: fix simplification of array-valued parameter expressions

gcc/fortran/ChangeLog:

PR fortran/102817
* expr.c (simplify_parameter_variable): Copy shape of referenced
subobject when simplifying.

gcc/testsuite/ChangeLog:

PR fortran/102817
* gfortran.dg/pr102817.f90: New test.

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-11-01 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #6 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2021-November/056914.html

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-11-01 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

--- Comment #5 from anlauf at gcc dot gnu.org ---
I'm testing the following fix:

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 4dea840e348..c5360dfaede 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2129,6 +2129,7 @@ simplify_parameter_variable (gfc_expr *p, int type)
return false;

   e->rank = p->rank;
+  e->shape = gfc_copy_shape (p->shape, p->rank);

   if (e->ts.type == BT_CHARACTER && p->ts.u.cl)
e->ts = p->ts;

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-10-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

--- Comment #4 from anlauf at gcc dot gnu.org ---
Furthermore the "scalar" variants work:

...
  type(t), parameter :: u= t(4)
...
  y = (u%a)
...

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-10-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

--- Comment #3 from anlauf at gcc dot gnu.org ---
Strange.  We happen to call gfc_free_shape with inconsistent data:

(gdb) p rank
$84 = 2
(gdb) p shape[1]
$85 = (mpz_t *) 0x0

Not good.

Interestingly the following works:

  integer :: z(1,2) = (x(1)%a)

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-10-19 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P4
   Target Milestone|--- |12.0

[Bug fortran/102817] [12 Regression] ICE in gfc_clear_shape, at fortran/expr.c:422 since r12-4278-g74ccca380cde5e79

2021-10-19 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102817

Martin Liška  changed:

   What|Removed |Added

Summary|[12 Regression] ICE in  |[12 Regression] ICE in
   |gfc_clear_shape, at |gfc_clear_shape, at
   |fortran/expr.c:422  |fortran/expr.c:422 since
   ||r12-4278-g74ccca380cde5e79
   Last reconfirmed||2021-10-19
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
 CC||anlauf at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org

--- Comment #2 from Martin Liška  ---
Started with r12-4278-g74ccca380cde5e79 with:

$ valgrind --trace-children=yes gfortran pr102817.f90 -c
==19067== Memcheck, a memory error detector
==19067== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19067== Using Valgrind-3.17.0.GIT and LibVEX; rerun with -h for copyright
info
==19067== Command: gfortran pr102817.f90 -c
==19067== 
==19074== Memcheck, a memory error detector
==19074== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19074== Using Valgrind-3.17.0.GIT and LibVEX; rerun with -h for copyright
info
==19074== Command:
/home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/f951 pr102817.f90
-quiet -dumpbase pr102817.f90 -dumpbase-ext .f90 -mtune=generic -march=x86-64
-fintrinsic-modules-path
/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/12.0.0/finclude
-fpre-include=/usr/include/finclude/math-vector-fortran.h -o /tmp/ccfJ3EKQ.s
==19074== 
==19074== Invalid read of size 4
==19074==at 0x4B52590: __gmpz_clear (clear.c:38)
==19074==by 0x8F92DB: gfc_clear_shape(__mpz_struct (*) [1], int)
(expr.c:422)
==19074==by 0x8F9314: gfc_free_shape(__mpz_struct (**) [1], int)
(expr.c:432)
==19074==by 0x8F9417: free_expr0(gfc_expr*) (expr.c:513)
==19074==by 0x8F95E4: gfc_replace_expr(gfc_expr*, gfc_expr*) (expr.c:626)
==19074==by 0x8FE3F2: remove_subobject_ref (expr.c:1483)
==19074==by 0x8FE3F2: simplify_const_ref(gfc_expr*) (expr.c:2001)
==19074==by 0x8FEE71: gfc_simplify_expr(gfc_expr*, int) (expr.c:2314)
==19074==by 0x8FF267: simplify_parameter_variable(gfc_expr*, int) [clone
.part.0] (expr.c:2143)
==19074==by 0x8FF0D0: simplify_parameter_variable (expr.c:2086)
==19074==by 0x8FF0D0: gfc_simplify_expr(gfc_expr*, int) (expr.c:2281)
==19074==by 0x8FEBE6: simplify_intrinsic_op (expr.c:1190)
==19074==by 0x8FEBE6: gfc_simplify_expr(gfc_expr*, int) (expr.c:2270)
==19074==by 0x97EFD1: resolve_operator(gfc_expr*) (resolve.c:4470)
==19074==by 0x97B777: gfc_resolve_expr (resolve.c:7136)
==19074==by 0x97B777: gfc_resolve_expr(gfc_expr*) (resolve.c:7105)
==19074==  Address 0x51a4450 is 0 bytes after a block of size 16 alloc'd
==19074==at 0x484315C: calloc (vg_replace_malloc.c:1117)
==19074==by 0x1EA2BD4: xcalloc (xmalloc.c:164)
==19074==by 0x8F9A35: gfc_copy_shape(__mpz_struct (*) [1], int)
(expr.c:814)
==19074==by 0x8F9BC3: gfc_copy_expr(gfc_expr*) (expr.c:405)
==19074==by 0x8FF2C8: simplify_parameter_variable(gfc_expr*, int) [clone
.part.0] (expr.c:2127)
==19074==by 0x8FF0D0: simplify_parameter_variable (expr.c:2086)
==19074==by 0x8FF0D0: gfc_simplify_expr(gfc_expr*, int) (expr.c:2281)
==19074==by 0x8FEBE6: simplify_intrinsic_op (expr.c:1190)
==19074==by 0x8FEBE6: gfc_simplify_expr(gfc_expr*, int) (expr.c:2270)
==19074==by 0x97EFD1: resolve_operator(gfc_expr*) (resolve.c:4470)
==19074==by 0x97B777: gfc_resolve_expr (resolve.c:7136)
==19074==by 0x97B777: gfc_resolve_expr(gfc_expr*) (resolve.c:7105)
==19074==by 0x986732: gfc_resolve_code(gfc_code*, gfc_namespace*)
(resolve.c:11908)
==19074==by 0x98ADA1: resolve_codes(gfc_namespace*) (resolve.c:17512)
==19074==by 0x975E38: gfc_resolve (resolve.c:17547)
==19074==by 0x975E38: gfc_resolve(gfc_namespace*) (resolve.c:17526)