public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972
@ 2021-11-16 18:33 gscfq@t-online.de
2021-11-16 18:34 ` [Bug fortran/103283] " gscfq@t-online.de
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2021-11-16 18:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
Bug ID: 103283
Summary: ICE in gfc_trans_array_constructor_subarray, at
fortran/trans-array.c:1972
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
type t
integer :: a(1) = 2
end type
type(t), parameter :: x(1) = [t(3)]
integer :: y(1)
y = [(x(1)%a)]
print *, y(1)
end
$ cat z2.f90
program p
type t
integer :: a(1) = 2
end type
type(t), parameter :: x(1) = [t(3)]
associate (y => [(x(1)%a)])
print *, y(1)
end associate
end
$ gfortran-12-20211114 -c z1.f90
z1.f90:7:17:
7 | y = [(x(1)%a)]
| 1
internal compiler error: in gfc_trans_array_constructor_subarray, at
fortran/trans-array.c:1972
0x85c45d gfc_trans_array_constructor_subarray
../../gcc/fortran/trans-array.c:1972
0x85c45d gfc_trans_array_constructor_value
../../gcc/fortran/trans-array.c:2100
0x85cdaa trans_array_constructor
../../gcc/fortran/trans-array.c:2900
0x85cdaa gfc_add_loop_ss_code
../../gcc/fortran/trans-array.c:3180
0x85d475 gfc_conv_loop_setup(gfc_loopinfo*, locus*)
../../gcc/fortran/trans-array.c:5430
0x890fad gfc_trans_assignment_1
../../gcc/fortran/trans-expr.c:11642
0x84ed67 trans_code
../../gcc/fortran/trans.c:1916
0x87801e gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:7644
0x7fb32e translate_all_program_units
../../gcc/fortran/parse.c:6638
0x7fb32e gfc_parse_file()
../../gcc/fortran/parse.c:6925
0x84806f gfc_be_parse_file
../../gcc/fortran/f95-lang.c:216
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/103283] ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972
2021-11-16 18:33 [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972 gscfq@t-online.de
@ 2021-11-16 18:34 ` gscfq@t-online.de
2021-11-30 21:34 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2021-11-16 18:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
G. Steinmetz <gscfq@t-online.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---
With simplified array constructor :
$ cat z3.f90
program p
type t
integer :: a(1) = 2
end type
type(t), parameter :: x(1) = [t(3)]
integer :: y(1)
y = [x(1)%a]
print *, y(1)
end
$ gfortran-12-20211114 z3.f90 && ./a.out
3
$
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/103283] ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972
2021-11-16 18:33 [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972 gscfq@t-online.de
2021-11-16 18:34 ` [Bug fortran/103283] " gscfq@t-online.de
@ 2021-11-30 21:34 ` anlauf at gcc dot gnu.org
2021-11-30 21:41 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-11-30 21:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2021-11-30
CC| |anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
Reduced testcase:
program p
type t
integer :: a(1) = 2
end type
type(t), parameter :: x(1) = t(3)
print *, (x(1)%a) ! ICE
end
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/103283] ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972
2021-11-16 18:33 [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972 gscfq@t-online.de
2021-11-16 18:34 ` [Bug fortran/103283] " gscfq@t-online.de
2021-11-30 21:34 ` anlauf at gcc dot gnu.org
@ 2021-11-30 21:41 ` anlauf at gcc dot gnu.org
2021-12-03 21:22 ` anlauf at gcc dot gnu.org
2021-12-04 21:07 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-11-30 21:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
--- Comment #3 from anlauf at gcc dot gnu.org ---
There's more to it:
program p
type t
integer :: a(1) = 2
end type
type(t), parameter :: x(1) = t(3)
integer, parameter :: k(*) = x(1)%a
end
This fails with:
pr103283-z1.f90:6:28:
6 | integer, parameter :: k(*) = x(1)%a
| 1
Error: Cannot initialize implied-shape array at (1) with scalar
Funny.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/103283] ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972
2021-11-16 18:33 [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972 gscfq@t-online.de
` (2 preceding siblings ...)
2021-11-30 21:41 ` anlauf at gcc dot gnu.org
@ 2021-12-03 21:22 ` anlauf at gcc dot gnu.org
2021-12-04 21:07 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-12-03 21:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #3)
> integer, parameter :: k(*) = x(1)%a
>
> This fails with:
>
> pr103283-z1.f90:6:28:
>
> 6 | integer, parameter :: k(*) = x(1)%a
> | 1
> Error: Cannot initialize implied-shape array at (1) with scalar
Doing some debugging, we seem to lose the shape when simplifying the r.h.s.
near the end of expr.c::simplify_parameter_variable:
/* Do not copy subobject refs for constant. */
if (e->expr_type != EXPR_CONSTANT && p->ref != NULL)
e->ref = gfc_copy_ref (p->ref);
t = gfc_simplify_expr (e, type);
Initially the ref looks fine, but it might be evaluated improperly.
We end up with a scalar instead of a rank-1 array.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/103283] ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972
2021-11-16 18:33 [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972 gscfq@t-online.de
` (3 preceding siblings ...)
2021-12-03 21:22 ` anlauf at gcc dot gnu.org
@ 2021-12-04 21:07 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-12-04 21:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
--- Comment #5 from anlauf at gcc dot gnu.org ---
I did get some progress with the attempt:
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 87089321a3b..d5bbcd493b6 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1929,6 +1929,8 @@ simplify_const_ref (gfc_expr *p)
/* Fall through. */
case AR_FULL:
+ if (p->ref->next == NULL)
+ return true;
if (p->ref->next != NULL
&& (p->ts.type == BT_CHARACTER || gfc_bt_struct
(p->ts.type)))
{
which fixes testcase z1.f90 as well as comment#3, but has a lot of regressions
in the testsuite.
But then I have to admit I do not understand that function well enough to fix
it.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-12-04 21:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 18:33 [Bug fortran/103283] New: ICE in gfc_trans_array_constructor_subarray, at fortran/trans-array.c:1972 gscfq@t-online.de
2021-11-16 18:34 ` [Bug fortran/103283] " gscfq@t-online.de
2021-11-30 21:34 ` anlauf at gcc dot gnu.org
2021-11-30 21:41 ` anlauf at gcc dot gnu.org
2021-12-03 21:22 ` anlauf at gcc dot gnu.org
2021-12-04 21:07 ` 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).