public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension
@ 2022-02-02 18:41 gscfq@t-online.de
2022-02-25 20:27 ` [Bug fortran/104350] " anlauf at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2022-02-02 18:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350
Bug ID: 104350
Summary: ICE in gfc_array_dimen_size(): Bad dimension
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Affects versions down to at least r5 :
$ cat z1.f90
program p
integer :: x(1) = 1
integer :: k
print *, product([(size(x, dim=k), k=0,rank(x))])
end
$ cat z2.f90
program p
integer :: x(0) = 0
integer :: k
print *, product([(size(x, dim=k), k=0,rank(x))])
end
$ cat z3.f90
program p
integer :: x(1) = 1
integer :: k
print *, product([(size(x, dim=k), k=1,2)])
end
$ cat z4.f90
program p
integer :: x(1) = 1
integer :: k
print *, product([(size(x, dim=k), k=-3,3)])
end
$ gfortran-12-20220130 -c z1.f90
f951: internal compiler error: gfc_array_dimen_size(): Bad dimension
0x6ec739 gfc_report_diagnostic
../../gcc/fortran/error.cc:883
0x6ee2b7 gfc_internal_error(char const*, ...)
../../gcc/fortran/error.cc:1503
0x6bc99f gfc_array_dimen_size(gfc_expr*, int, __mpz_struct (*) [1])
../../gcc/fortran/array.cc:2574
0x77896f simplify_size
../../gcc/fortran/simplify.cc:7580
0x786995 gfc_simplify_size(gfc_expr*, gfc_expr*, gfc_expr*)
../../gcc/fortran/simplify.cc:7601
0x70276a do_simplify
../../gcc/fortran/intrinsic.cc:4676
0x70d538 gfc_intrinsic_func_interface(gfc_expr*, int)
../../gcc/fortran/intrinsic.cc:4941
0x6f346c gfc_simplify_expr(gfc_expr*, int)
../../gcc/fortran/expr.cc:2220
0x6b9e11 expand_constructor
../../gcc/fortran/array.cc:1827
0x6ba0be expand_expr
../../gcc/fortran/array.cc:1685
0x6ba0be expand_iterator
../../gcc/fortran/array.cc:1755
0x6ba0be expand_constructor
../../gcc/fortran/array.cc:1798
0x6bc1f7 gfc_array_size(gfc_expr*, __mpz_struct (*) [1])
../../gcc/fortran/array.cc:2665
0x75e30f expression_shape
../../gcc/fortran/resolve.cc:5501
0x75e30f gfc_expression_rank(gfc_expr*)
../../gcc/fortran/resolve.cc:5575
0x75fbdf gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.cc:7205
0x763cbf gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.cc:2217
0x763cbf resolve_actual_arglist
../../gcc/fortran/resolve.cc:2136
0x75f96e resolve_function
../../gcc/fortran/resolve.cc:3274
0x75f96e gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.cc:7169
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
2022-02-02 18:41 [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension gscfq@t-online.de
@ 2022-02-25 20:27 ` anlauf at gcc dot gnu.org
2023-05-23 20:51 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-02-25 20:27 UTC (permalink / raw)
To: gcc-bugs
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. :-(
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
2022-02-02 18:41 [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension gscfq@t-online.de
2022-02-25 20:27 ` [Bug fortran/104350] " anlauf at gcc dot gnu.org
@ 2023-05-23 20:51 ` anlauf at gcc dot gnu.org
2023-05-24 19:16 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-05-23 20:51 UTC (permalink / raw)
To: gcc-bugs
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&action=edit
Better patch.
This patch seems to work and regtest ok.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
2022-02-02 18:41 [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension gscfq@t-online.de
2022-02-25 20:27 ` [Bug fortran/104350] " anlauf at gcc dot gnu.org
2023-05-23 20:51 ` anlauf at gcc dot gnu.org
@ 2023-05-24 19:16 ` anlauf at gcc dot gnu.org
2023-05-24 19:51 ` cvs-commit at gcc dot gnu.org
2023-05-25 17:14 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-05-24 19:16 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
2022-02-02 18:41 [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension gscfq@t-online.de
` (2 preceding siblings ...)
2023-05-24 19:16 ` anlauf at gcc dot gnu.org
@ 2023-05-24 19:51 ` cvs-commit at gcc dot gnu.org
2023-05-25 17:14 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-24 19:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:ec2e86274427a402d2de2199ba550f7295ea9b5f
commit r14-1175-gec2e86274427a402d2de2199ba550f7295ea9b5f
Author: Harald Anlauf <anlauf@gmx.de>
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
2022-02-02 18:41 [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension gscfq@t-online.de
` (3 preceding siblings ...)
2023-05-24 19:51 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25 17:14 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-05-25 17:14 UTC (permalink / raw)
To: gcc-bugs
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!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-05-25 17:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 18:41 [Bug fortran/104350] New: ICE in gfc_array_dimen_size(): Bad dimension gscfq@t-online.de
2022-02-25 20:27 ` [Bug fortran/104350] " anlauf at gcc dot gnu.org
2023-05-23 20:51 ` anlauf at gcc dot gnu.org
2023-05-24 19:16 ` anlauf at gcc dot gnu.org
2023-05-24 19:51 ` cvs-commit at gcc dot gnu.org
2023-05-25 17:14 ` anlauf at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).