From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 826833858C30; Wed, 31 May 2023 17:11:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 826833858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685553088; bh=VuXCYWsLxC59oK0SNe70g00lwonekN4Z8L+keVujZbE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NJul1X1QwjHUDsfc71jWyFmgEa54WlmtLuAG6f91DPmNjpF6tShxSvUmmHr8nDui3 J/zJnB5rlS/HzpabUVFcpVp+qPGMI27OHDSjDGncYmQSZ8+NPLIIjwsDHoGzwMYcKr sAqu/6hDwbgy4MnZeTUDFs4nQngzgRNe2GvCfnV4= 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: Wed, 31 May 2023 17:11:25 +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: pault at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to attachments.created 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 ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gn= u.org --- Comment #15 from Paul Thomas --- Created attachment 55225 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55225&action=3Dedit Fix for this PR The attached patch substantially tidies up parse_associate and fixes: ! { dg-do run } ! ! Tests the fix for PR109948 ! module mm implicit none interface operator(=3D=3D) module procedure eq_1_2 end interface operator(=3D=3D) private :: eq_1_2 contains logical function eq_1_2 (x, y) integer, intent(in) :: x(:) real, intent(in) :: y(:,:) eq_1_2 =3D .true. end function eq_1_2 end module mm program pr109948 use mm implicit none type tlap integer, allocatable :: z(:) end type tlap type ulap type(tlap) :: u(2) end type ulap integer :: pid =3D 1 call comment0 ! Original problem call comment1 call comment3 ([5,4,3,2,1]) call comment10 call comment11 ([5,4,3,2,1]) contains subroutine comment0 type(tlap) :: y_in integer :: x_out(3) =3D[0.0,0.0,0.0] y_in%z =3D [1,-2,3] call foo(y_in, x_out) if (any (x_out .ne. [0, -2, 0])) stop 1 call foo(y_in, x_out) if (any (x_out .ne. [1, -2, 3])) stop 2 end subroutine comment0 subroutine foo(y, x) type(tlap) :: y integer :: x(:) associate(z=3D>y%z) if (pid =3D=3D 1) then where ( z < 0 ) x(:) =3D z(:) else where ( z > 0 ) x(:) =3D z(:) endif pid =3D pid + 1 end associate end subroutine foo subroutine comment1 type(tlap) :: grib integer :: i grib%z =3D [3,2,1] associate(k=3D>grib%z) i =3D k(1) if (any(k=3D=3D1)) i =3D 1 end associate if (i .eq. 3) stop 3 end subroutine comment1 subroutine comment3(k_2d) implicit none integer :: k_2d(:) integer :: i associate(k=3D>k_2d) i =3D k(1) if (any(k=3D=3D1)) i =3D 1 end associate if (i .eq. 3) stop 4 end subroutine comment3 subroutine comment11(k_2d) implicit none integer :: k_2d(:) integer :: m(1) =3D 42 real :: r(1,1) =3D 3.0 if ((m =3D=3D r) .neqv. .true.) stop 5 associate (k=3D>k_2d) if ((k =3D=3D r) .neqv. .true.) stop 6 ! failed to find user defined operator end associate associate (k=3D>k_2d(:)) if ((k =3D=3D r) .neqv. .true.) stop 7 end associate end subroutine comment11 subroutine comment10 implicit none type(ulap) :: z(2) integer :: i real :: r(1,1) =3D 3.0 z(1)%u =3D [tlap([1,2,3]),tlap([4,5,6])] z(2)%u =3D [tlap([7,8,9]),tlap([10,11,12])] associate (k=3D>z(2)%u(1)%z) i =3D k(1) if (any(k=3D=3D8)) i =3D 1 end associate if (i .ne. 1) stop 8 associate (k=3D>z(1)%u(2)%z) if ((k =3D=3D r) .neqv. .true.) stop 9 if (any (k .ne. [4,5,6])) stop 10 end associate end subroutine comment10 end program pr109948=