From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D12E83858D3C; Fri, 26 May 2023 09:47:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D12E83858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685094461; bh=NVeZKO3WlOwK+mt6VIr6Ny+7VQ8QAVi4KaE1JkTHkc8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qwz3hzCU5awxqFBI8CSwJvsftw0zywxoRgLwqMvhq1mJnIECtJHQxh18QD2ERCJEI pB2/QWYlG4ujYhclO+3QG5Gg92F4MOlEODvY/18vs0p5e4XF1iPTtIEDXnExJj3+hy KygM1P96FXZfX5xy7I02IVeYAuWWsX5z9nW75qt4= From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109948] [13/14 Regression] ICE(segfault) in gfc_expression_rank() from gfc_op_rank_conformable() Date: Fri, 26 May 2023 09:47:40 +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: 13.1.1 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: blocked 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109948 Paul Thomas changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |87477 --- Comment #8 from Paul Thomas --- I have flagged that this PR blocks PR87477. Guarding ref->u.ar.as is good practice. However, it turns out that the associate name symbol has a perfectly good array_spec. This version "double fixes" the PR and is somewhat more satisfactory. diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 83e45f1b693..9863cdc1583 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -5640,7 +5640,12 @@ gfc_expression_rank (gfc_expr *e) if (ref->type !=3D REF_ARRAY) continue; - if (ref->u.ar.type =3D=3D AR_FULL) + if (ref->u.ar.as =3D=3D NULL + && e->expr_type =3D=3D EXPR_VARIABLE + && e->symtree->n.sym->as) + ref->u.ar.as =3D e->symtree->n.sym->as; + + if (ref->u.ar.type =3D=3D AR_FULL && ref->u.ar.as) { rank =3D ref->u.ar.as->rank; break; Gratifyingly, this does the right thing: implicit none type tlap real, allocatable :: z(:) end type tlap type(tlap) :: y_in real :: x_out(3) =3D[0.0,0.0,0.0] integer :: pid =3D 1 y_in%z =3D [1.0,-2.0,3.0] call foo(y_in, x_out) print *, x_out call foo(y_in, x_out) print *, x_out contains subroutine foo(y, x) type(tlap) :: y real :: x(:) associate(z=3D>y%z) if (getpid() =3D=3D 1) then where ( z < 0.0 ) x(:) =3D z(:) else where ( z > 0.0 ) x(:) =3D z(:) endif end associate end subroutine foo integer function getpid() getpid =3D pid pid =3D pid + 1 end function getpid end Cheers Paul Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D87477 [Bug 87477] [meta-bug] [F03] issues concerning the ASSOCIATE statement=