[Bug fortran/103794] ICE in gfc_check_reshape, at fortran/check.c:4727

2023-05-25 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103794

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Fixed for gcc-14.  Closing.

Thanks for the report!

[Bug fortran/103794] ICE in gfc_check_reshape, at fortran/check.c:4727

2023-05-24 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103794

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

https://gcc.gnu.org/g:5fd5d8fb744fd9251d04e4b17d04f2340e6a283b

commit r14-1174-g5fd5d8fb744fd9251d04e4b17d04f2340e6a283b
Author: Harald Anlauf 
Date:   Sun May 21 22:25:29 2023 +0200

Fortran: checking and simplification of RESHAPE intrinsic [PR103794]

gcc/fortran/ChangeLog:

PR fortran/103794
* check.cc (gfc_check_reshape): Expand constant arguments SHAPE and
ORDER before checking.
* gfortran.h (gfc_is_constant_array_expr): Add prototype.
* iresolve.cc (gfc_resolve_reshape): Expand constant argument
SHAPE.
* simplify.cc (is_constant_array_expr): If array is determined to
be
constant, expand small array constructors if needed.
(gfc_is_constant_array_expr): Wrapper for is_constant_array_expr.
(gfc_simplify_reshape): Fix check for insufficient elements in
SOURCE
when no padding specified.

gcc/testsuite/ChangeLog:

PR fortran/103794
* gfortran.dg/reshape_10.f90: New test.
* gfortran.dg/reshape_11.f90: New test.

[Bug fortran/103794] ICE in gfc_check_reshape, at fortran/check.c:4727

2023-05-21 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103794

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org
   Keywords||wrong-code

--- Comment #2 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-May/059317.html

[Bug fortran/103794] ICE in gfc_check_reshape, at fortran/check.c:4727

2021-12-21 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103794

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Last reconfirmed||2021-12-21
 CC||anlauf at gcc dot gnu.org
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.  We're not trying hard enough to simplify constant expressions
involving iterators.

The following fixes the testcases, but may not be the best/generic solution:

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index b4db9337e9f..9f597ccb4b4 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "intrinsic.h"
 #include "constructor.h"
 #include "target-memory.h"
+#include "match.h"


 /* Reset a BOZ to a zero value.  This is used to prevent run-on errors
@@ -4721,6 +4722,7 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
 {
   gfc_expr *e;
   int i, extent;
+  gfc_reduce_init_expr (shape);
   for (i = 0; i < shape_size; ++i)
{
  e = gfc_constructor_lookup_expr (shape->value.constructor, i);