From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B57C63858C62; Sun, 27 Nov 2022 01:03:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B57C63858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669511006; bh=FS3iD+ZzVnpLamb21wgziO+TfBxjKuxLs9w2SoaA1So=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Db81PPlwK39OiCHrnGFy6twg/JCbMDsBvoDVf8WO7hbCEcX1iUwnUjYZhthntbLuN d89WAtofFc6xLKHZQarnNImN5qsKMVNQDZ9imikxQh8cmOM+yuMva7dlcrKBw+SmaR QbagsIE7+rxce+x1lU8Ymwi1qqNUTjyCNlo9QdpQ= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107874] merge not using all its arguments Date: Sun, 27 Nov 2022 01:03:20 +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: unknown X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D107874 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #2 from kargl at gcc dot gnu.org --- John thanks for posting the bug. Harald, you are likely right the patch can be moved down. I'll programmed = up the example from the Fortran 2018 standard, which works as expected. So, t= here is definitely something about a scalar mask choosing the actual argument be= fore both are evaluated. program foo call bah contains subroutine bah logical, parameter :: t =3D .true., f =3D .false. logical, parameter :: mask(2,3)=3D reshape([t, f, f, f, t, t], [2= ,3]) integer tsrc(2,3), fsrc(2,3), res(2,3) ! ! Direct reference to merge ! tsrc =3D reshape([1, 2, 6, 4, 5, 6], [2,3]) fsrc =3D reshape([0, 7, 3, 4, 2, 8], [2,3]) res =3D 42 res =3D merge(tsrc, fsrc, mask) write(*,'(*(I0,1X))') res(1,:) ! Should be 1 3 5 write(*,'(*(I0,1X))') res(2,:) ! Should be 7 4 6 write(*,*) ! ! Load matrices via a function. ! res =3D 0 ! Clear res =3D merge(load('t'), load('f'), mask) ! Clear write(*,'(*(I0,1X))') res(1,:) ! Should be 1 3 5 write(*,'(*(I0,1X))') res(2,:) ! Should be 7 4 6=20=20=20=20 end subroutine bah function load(c) result(r) integer r(2,3) character, intent(in) :: c if (c =3D=3D 't') then r =3D reshape([1, 2, 6, 4, 5, 6], [2,3]) print *, 'loaded t' else if (c =3D=3D 'f') then r =3D reshape([0, 7, 3, 4, 2, 8], [2,3]) print *, 'loaded f' else stop 'whoops' end if end function load end program foo=