https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94048
Bug ID: 94048 Summary: ICE and other problems using rank intrinsic to set array size Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jrfsousa at gmail dot com Target Milestone: --- Created attachment 47978 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47978&action=edit Code demonstrating problems. Hi all! ICE using rank to set the size of an array. Both in: GNU Fortran (GCC) 9.2.1 20200303 and GNU Fortran (GCC) 10.0.1 20200303 (experimental) The ICE is easy to fix: diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 79e00b4..a5993ea 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3253,7 +3253,7 @@ check_references (gfc_ref* ref, bool (*checker) (gfc_expr*)) switch (ref->type) { case REF_ARRAY: - for (dim = 0; dim != ref->u.ar.dimen; ++dim) + for (dim = 0; dim < ref->u.ar.dimen; ++dim) { if (!checker (ref->u.ar.start[dim])) return false; On x86_64-pc-linux-gnu it tests OK. The real problems start after that... :-) Using the module generates: f951: Fatal Error: Reading module ‘ice2_m.mod’ at line 23 column 6: Bad name compilation terminated. Using the function by itself returns a malformed array, compiling with -fbounds-check generates the error: At line 11 of file ./ice2.f90 Fortran runtime error: Dimension 1 of array 'bar' has extent 1 instead of -1 I belive that the error is at the interface and the ifm.n artificial variable is not properly generated. Thank you very much. Best regards, José Rui