[Bug ada/70867] access discriminant in return aggregate detected as dangling if set from an implicit dereference in generic package
demoonlit at panathenaia dot halfmoon.jp
gcc-bugzilla@gcc.gnu.org
Fri Apr 29 06:42:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867
yuta tomino <demoonlit at panathenaia dot halfmoon.jp> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |demoonlit at panathenaia dot halfm
| |oon.jp
--- Comment #1 from yuta tomino <demoonlit at panathenaia dot halfmoon.jp> ---
Hello. I have encountered a similar case, too.
package p is
type T (D : access constant Integer) is null record;
type R is limited record
Component : aliased Integer;
end record;
function F (Object : R) return T is
(D => Object.Component'Access);
end p;
p.ads:7:12: access discriminant in return aggregate would be a dangling
reference
Inserting "aliased" between "Object :" and "R" resolves it.
However, "Object : R" is already passed by reference without aliased, because
in RM 6.2(7/3), an explicitly limited record type is a by-reference type unless
aliased.
So, it does not make a dangling reference.
More information about the Gcc-bugs
mailing list