This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/70867] New: access discriminant in return aggregate detected as dangling if set from an implicit dereference in generic package
- From: "nicolas.boulenguez at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Apr 2016 05:48:57 +0000
- Subject: [Bug ada/70867] New: access discriminant in return aggregate detected as dangling if set from an implicit dereference in generic package
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867
Bug ID: 70867
Summary: access discriminant in return aggregate detected as
dangling if set from an implicit dereference in
generic package
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: nicolas.boulenguez at free dot fr
Target Milestone: ---
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.
-- Content of p.ads.
generic
package P is
type T (D : access Integer) is null record;
type R is record
Item : aliased Integer;
end record;
function F (Position : access R) return T;
end P;
-- Content of p.adb.
package body P is
function F (Position : access R) return T is
begin
return (D => Position.Item'Access);
end F;
end P;