[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling

simon at pushface dot org gcc-bugzilla@gcc.gnu.org
Sat Jul 31 20:11:15 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867

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 := (Item => 42);
   T : Q.T := Q.F (R'Access);
begin
   Ada.Text_IO.Put_Line (T.D.all'Image);
end P_Test;


More information about the Gcc-bugs mailing list