From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 085CA3858003; Sat, 31 Jul 2021 20:11:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 085CA3858003 From: "simon at pushface dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling Date: Sat, 31 Jul 2021 20:11:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ada X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simon at pushface dot 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: 9.5 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 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: Sat, 31 Jul 2021 20:11:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D70867 simon at pushface dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simon at pushface dot org --- Comment #14 from simon at pushface dot org --- (In reply to Nicolas Boulenguez from comment #0) > Hello. > With GCC-6 (Debian 6.0.1-2) 6.0.1 20160423 (prerelease), > compiling the following package with "gcc-6 -c p.adb" fails: > p.adb:4:20: access discriminant in return aggregate would be a dangling > reference > The code compiles > - if the "generic" line is removed > - or if ".all" is inserted between "Position" and ".Item'Access" > I am not sure whether returning this reference is allowed by the Ada > Reference Manual, > but the semantics of "generic" and ".all" should certainly not affect the > answer. GCC 11.1.0, x86_64-apple-darwin on macOS 11.6 (Big Sur): This compiles without error, and the example below executes correctly. with P; with Ada.Text_IO; procedure P_Test is package Q is new P; R : aliased Q.R :=3D (Item =3D> 42); T : Q.T :=3D Q.F (R'Access); begin Ada.Text_IO.Put_Line (T.D.all'Image); end P_Test;=