public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110723] New: ICE with allocatable character lhs and parenthesized array with vector subscript
@ 2023-07-18 16:46 anlauf at gcc dot gnu.org
2023-07-18 17:01 ` [Bug fortran/110723] " anlauf at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-18 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110723
Bug ID: 110723
Summary: ICE with allocatable character lhs and parenthesized
array with vector subscript
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: anlauf at gcc dot gnu.org
Target Milestone: ---
Found while analyzing pr95947:
program p
implicit none
character(len=1) :: m(3) = ['a','b','c']
character(len=:), allocatable :: n(:)
n = m([2])
n = m([2,3])
n = (m([2])) ! ICE
n = (m([2,3])) ! ICE
end
We end up with EXPR_OP in the assignment for the parenthesized variants,
leading to bad gimple.
Tentative fix:
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index ef3e6d08f78..63d39c2516e 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -11954,6 +11954,12 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr *
expr2, bool init_flag,
rss = NULL;
+ /* Strip left-over parentheses around rhs variables (not expressions). */
+ while (expr2->expr_type == EXPR_OP
+ && expr2->value.op.op == INTRINSIC_PARENTHESES
+ && expr2->value.op.op1->expr_type == EXPR_VARIABLE)
+ expr2 = expr2->value.op.op1;
+
if (expr2->expr_type != EXPR_VARIABLE
&& expr2->expr_type != EXPR_CONSTANT
&& (expr2->ts.type == BT_CLASS || gfc_may_be_finalized (expr2->ts)))
Not sure if this is the right place.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/110723] ICE with allocatable character lhs and parenthesized array with vector subscript
2023-07-18 16:46 [Bug fortran/110723] New: ICE with allocatable character lhs and parenthesized array with vector subscript anlauf at gcc dot gnu.org
@ 2023-07-18 17:01 ` anlauf at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-18 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110723
--- Comment #1 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #0)
> Not sure if this is the right place.
Actually, the following still fails:
n = (m([2])//"") ! ICE
:-(
Generally stripping parentheses generates a failure in
gfortran.dg/reassoc_2.f90, which is bad...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-18 17:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 16:46 [Bug fortran/110723] New: ICE with allocatable character lhs and parenthesized array with vector subscript anlauf at gcc dot gnu.org
2023-07-18 17:01 ` [Bug fortran/110723] " 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).