[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-06 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

G. Steinmetz  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code

--- Comment #1 from G. Steinmetz  ---


Error detected with a constant instead :


$ cat z2.f90
program p
   real, allocatable :: x[:,:]
   integer, parameter :: n = 2
   allocate (x[::n, *])
end


$ cat z3.f90
program p
   real, allocatable :: x[:,:]
   allocate (x[::2, *])
end


$ gfortran-12-20220403 -c z2.f90 -fcoarray=single
z2.f90:4:15:

4 |allocate (x[::n, *])
  |   1
Error: Bad array dimension at (1)

[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-06 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2022-04-06

--- Comment #2 from anlauf at gcc dot gnu.org ---
Confirmed.

The checking for bad array shape specifications needs improvement.

[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-06 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
Testing the following patch:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 21c8797c938..45a04dab703 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -8108,12 +8108,12 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code,
bool *array_alloc_wo_spec)
goto failure;

  case  DIMEN_RANGE:
-   if (ar->start[i] == 0 || ar->end[i] == 0)
+   // F2018:R937:
+   // allocate-coshape-spec is [ lower-bound-expr : ] upper-bound-expr
+   if (ar->start[i] == 0 || ar->end[i] == 0 || ar->stride[i] != NULL)
  {
-   /* If ar->stride[i] is NULL, we issued a previous error.  */
-   if (ar->stride[i] == NULL)
- gfc_error ("Bad array specification in ALLOCATE statement "
-"at %L", &e->where);
+   gfc_error ("Bad array specification in ALLOCATE statement "
+  "at %L", &e->where);
goto failure;
  }
else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1)

[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-06 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-April/057743.html

[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

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

https://gcc.gnu.org/g:54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07

commit r12-8073-g54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07
Author: Harald Anlauf 
Date:   Wed Apr 6 22:24:21 2022 +0200

Fortran: fix checking of coshape specification in ALLOCATE statement

gcc/fortran/ChangeLog:

PR fortran/105184
* array.cc (match_subscript): Reject assumed size coarray
specification with missing lower bound.
* resolve.cc (resolve_allocate_expr): Fix logic for checking
allocate-coshape-spec in ALLOCATE statement.

gcc/testsuite/ChangeLog:

PR fortran/105184
* gfortran.dg/coarray_44.f90: Adjust expected output.
* gfortran.dg/coarray_allocate_11.f90: Likewise.
* gfortran.dg/coarray_allocate_12.f90: New test.

[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-10 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED
   Target Milestone|--- |12.0

--- Comment #6 from anlauf at gcc dot gnu.org ---
Fixed for gcc-12.  Closing.

Thanks for the report!

[Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841

2022-04-12 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105184

--- Comment #7 from G. Steinmetz  ---
Thank you very much for fixing this problem !