From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,57f8540942f8e060 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!15g2000yqi.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= Newsgroups: comp.lang.ada Subject: Re: Initialization and Finalization of limited object "returned" by a function Date: Thu, 11 Feb 2010 20:27:11 -0800 (PST) Organization: http://groups.google.com Message-ID: <52234b80-70a7-4711-8d07-6921f4ab35ef@15g2000yqi.googlegroups.com> References: <75a9f860-ad3c-49a0-b2a1-a8f1386e6ff6@x10g2000prk.googlegroups.com> <2801be3a-afd6-4d14-ad7f-feb23a511f02@a5g2000yqi.googlegroups.com> <0835a8bb-5264-44f8-9b58-1f8cff5f9f0a@a32g2000yqm.googlegroups.com> NNTP-Posting-Host: 86.66.190.112 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1265948832 16981 127.0.0.1 (12 Feb 2010 04:27:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 12 Feb 2010 04:27:12 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 15g2000yqi.googlegroups.com; posting-host=86.66.190.112; posting-account=vrfdLAoAAAAauX_3XwyXEwXCWN3A1l8D User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; fr),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9152 Date: 2010-02-11T20:27:11-08:00 List-Id: Back here (I was busy at some intermediate things). It seems to me, there is indeed a GNAT bug here, as this next sample which solve the trouble shows. With G, initialization and finalization are done just like I was expecting. procedure G is -- Variation from G : the protected -- type is wrapped in a limited record -- which is handle the derivation of -- the Limited_Type. -- Observations : Entity is initialized -- and Finalized as expected (like in A), -- and its component of Protected_Type is -- initialized before Entity is Initialized -- (as expected) and Finalized after -- Entity is Finalized (also as expected). -- It seems to me (unless there are contradictory -- interpretation of these observations), that -- a bug is confirmed here, and the construct -- provided here is a possible workaround. package P is type Limited_Type is limited interface; subtype Limited_Class is Limited_Type'Class; function New_Limited return Limited_Class; end P; package body P is protected type Protected_Type is end; protected body Protected_Type is end; type Derived_Limited_Type is limited new Limited_Type with record Wrapped_Protected_Item : Protected_Type; end record; function New_Derived return Derived_Limited_Type is begin return R : Derived_Limited_Type do null; end return; end; function New_Limited return Limited_Class is begin return R: Limited_Class := New_Derived do null; end return; end; end P; Entity : P.Limited_Class := P.New_Limited; begin null; end G;