[Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350 anlauf at gcc dot gnu.org changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #5 from anlauf at gcc dot gnu.org --- Fixed for gcc-14. Closing. Thanks for the report!
[Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350 --- Comment #4 from CVS Commits --- The master branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:ec2e86274427a402d2de2199ba550f7295ea9b5f commit r14-1175-gec2e86274427a402d2de2199ba550f7295ea9b5f Author: Harald Anlauf Date: Wed May 24 21:04:43 2023 +0200 Fortran: reject bad DIM argument of SIZE intrinsic in simplification [PR104350] gcc/fortran/ChangeLog: PR fortran/104350 * simplify.cc (simplify_size): Reject DIM argument of intrinsic SIZE with error when out of valid range. gcc/testsuite/ChangeLog: PR fortran/104350 * gfortran.dg/size_dim_2.f90: New test.
[Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350 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 #3 from anlauf at gcc dot gnu.org --- Submitted: https://gcc.gnu.org/pipermail/fortran/2023-May/059322.html
[Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350 anlauf at gcc dot gnu.org changed: What|Removed |Added CC||anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- Created attachment 55145 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55145=edit Better patch. This patch seems to work and regtest ok.
[Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350 anlauf at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed||2022-02-25 --- Comment #1 from anlauf at gcc dot gnu.org --- Confirmed. There are multiple ways to avoid the ICE: - replace gfc_internal_error in gfc_array_dimen_size by gfc_error, e.g. diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index f1d92e00c98..a42fb8f59fe 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "gfortran.h" #include "parse.h" +#include "intrinsic.h" #include "match.h" #include "constructor.h" @@ -2571,7 +2572,13 @@ gfc_array_dimen_size (gfc_expr *array, int dimen, mpz_t *result) return false; if (dimen < 0 || dimen > array->rank - 1) -gfc_internal_error ("gfc_array_dimen_size(): Bad dimension"); +{ + gfc_error ("DIM argument (%d) to intrinsic %qs at %L out of range " +"(1:%d)", dimen+1, gfc_current_intrinsic, +gfc_current_intrinsic_where, array->rank); + return false; +} +//gfc_internal_error ("gfc_array_dimen_size(): Bad dimension"); switch (array->expr_type) { This however produces two error messages of the kind: pr104350-z1.f90:4:21: 4 | print *, product([(size(x, dim=k), k=0,rank(x))]) | 1 Error: DIM argument (0) to intrinsic 'size' at (1) out of range (1:1) pr104350-z1.f90:4:10: 4 | print *, product([(size(x, dim=k), k=0,rank(x))]) | 1 Error: DIM argument (0) to intrinsic 'product' at (1) out of range (1:1) The second error is misleading. :-( - a similar patch to simplify_size generates a similar error twice. :-(