http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55725
Bug #: 55725 Summary: Anonymous access returned from library-level function is finalized too early, RM 3.10.2(10/2 or 10.3/3) Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada AssignedTo: unassig...@gcc.gnu.org ReportedBy: demoon...@panathenaia.halfmoon.jp Created attachment 28989 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28989 minimal bug triggering source code An allocated object via anonymous access type returned from a library-level function like F may be finalized inside of the function. with Something; function F return access T; function F return access T is begin return new T; -- It returns new allocated value -- The allocated object may be finalized here end F; If a function is declared in a package, it behaves right. This bug has also been discussed on comp.lang.ada.