From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7ADF6388C013; Wed, 30 Dec 2020 18:12:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ADF6388C013 From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/98458] ICE in gfc_conv_array_initializer due to array expressions within implied do-loop Date: Wed, 30 Dec 2020 18:12:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pault at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Dec 2020 18:12:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98458 --- Comment #8 from Steve Kargl -= -- On Wed, Dec 30, 2020 at 01:40:22PM +0000, pault at gcc dot gnu.org wrote: > --- Comment #7 from Paul Thomas --- > (In reply to Steve Kargl from comment #6) >=20 > Hi Steve, >=20 > I didn't check for any new postings when I attached my version > of the patch. Apologies for treading on your toes.... again :-) You didn't step on any toes. I think your original patch is better than mine, because it applies to any place where is_constant_array_expr() is called. I suspect your patch is probably better placed someplace in gfc_simplify_expr(), but that is for another day. > > My proposed patch fixes the issue in one spot. Paul's > > patch fixes potentially many spots. Unfortunately, the > > handling of implied do-loops is done in an ad hoc fashion, > > and is complicated by the potential problem of exhausting > > the stack. >=20 > I like your use of gfc_reduce_init_expr since it also does > a type check. Note though that it resets gfc_reduce_init_expr > and so it needs to be set once again after the call. Ah, good point about resetting gfc_reduce_init_expr flag. When debugging the problem, I found that source=3D[ [1,2], [2,3], [3,4] ] so the implied do-loop was expanded, but the array was not simplified to [1, 2, 2, 3, 3, 4]. This was causing=20 gfc_simplify_reshape to return NULL.=20 > I had totally forgotten about the 'fatal' flag needing to be > set in the call to gfc_expand_constructor to avoid stack > exhaustion. I had to rediscover it experimentally. implied do-loops in PARAMETER statements have been a problem for a long time. I only remember the problem with exhausting the stack, because I chose flag_max_array_constructor =3D 65535. > A combined patch is being regtested now. Thanks.=