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);

Reply via email to