From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A11DD382FAF8; Thu, 24 Nov 2022 19:07:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A11DD382FAF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669316828; bh=73Bm5rXIs3nlm/cingkh5UXLwGB/gfJfgbIqlizueR4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EbkZECmny88LGkIIe8usw95/ZQ00LnsDxsBe+AiZrAIIJP2zDMfVLDdICu83wvJf2 XlYAM6VRrG3YPPEsnWK9Ih0FmqdzRNLYKAZ7LZ8MvUdpkimGNhhCA0S1CnXJTemalm 9sPwKPxpPyGv1dZqmqErT7Z8G1HVDNTEYsUC3Pyg= From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107819] ICE in gfc_check_argument_var_dependency, at fortran/dependency.cc:978 Date: Thu, 24 Nov 2022 19:07:07 +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.0 X-Bugzilla-Keywords: ice-on-invalid-code, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael 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: 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=3D107819 --- Comment #6 from Mikael Morin --- (In reply to anlauf from comment #5) > (In reply to Mikael Morin from comment #4) > > But is it required to generate a temporary? > > As I understand it, the code is invalid, and (correctly) diagnosed, so = there > > is nothing else to do. > > It's invalid because of 15.5.2.13 Restrictions on entities associated w= ith > > dummy arguments: > > (4) If the value of the entity or any subobject of it is affected throu= gh > > the dummy argument, then at any time during the invocation and executio= n of > > the procedure, either before or after the definition, it shall be refer= enced > > only through that dummy argument unless (...) >=20 > Right. >=20 > I was confused by two observations. First, NAG & Cray seem to generate > temporaries, while Intel and NVidia don't and would agree with gfortran > after the patch. >=20 > Second, I stumbled over: >=20 > ! 15.5.2.3 Argument association > ! (4) A present dummy argument with the VALUE attribute becomes argument > ! associated with a definable anonymous data object whose initial value is > ! the value of the actual argument. >=20 Ouch! You're right, this makes the part I quoted above irrelevant. And it explicitly asks for a temporary. > So it boils down to what ELEMENTAL actually means in that context. F2018: >=20 > 15.8.3 Elemental subroutine actual arguments >=20 > ! In a reference to an elemental subroutine, if the actual arguments > ! corresponding to INTENT(OUT) and INTENT(INOUT) dummy arguments are > ! arrays, the values of the elements, if any, of the results are the same > ! as would be obtained if the subroutine had been applied separately, in > ! array element order, to corresponding elements of each array actual > ! argument. >=20 > So I read this that >=20 > call s (a(n), a) >=20 > is to be interpreted as >=20 > do i =3D 1, size (a) > call s (a(n(i)), a(i)) > end do >=20 > and this would actually be well-defined behavior... ;-) With your quote from 15.5.2.3 above, it would be more like: do i =3D 1, size(a) tmp(i) =3D a(n(i)) end do do i =3D 1, size(a) call s(tmp(i), a(i)) end do=