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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,33ed4ca582c945fc,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Limited returns Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH Date: Mon, 23 Jun 2008 16:21:07 +0200 Message-ID: NNTP-Posting-Date: 23 Jun 2008 16:21:07 CEST NNTP-Posting-Host: 6ef3fd1c.newsspool3.arcor-online.net X-Trace: DXC=P^P\j^QNdkgeoCI^f\Y]EaMcF=Q^Z^V3h4Fo<]lROoRa8kFoYYf:GQ35RKd X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:817 Date: 2008-06-23T16:21:07+02:00 List-Id: Let's consider this: with Ada.Finalization; procedure Test_Limited_Stuff is type I is limited interface; type T is new Ada.Finalization.Limited_Controlled with record A : Integer; end record; type S is new T and I with record Self : not null access S'Class := S'Unchecked_Access; end record; function Factory return I'Class is begin return X : S; -- GNAT: wrong type for return_subtype_indication end Factory; begin null; end Test_Limited_Stuff; Is it illegal? I am surprised why? S is in I'Class. OK, if that is indeed illegal, then let's make another try: function Factory return I'Class is begin return X : I'Class := S'(T with others => <>); -- GNAT: expected an access type with designated type "S'Class" defined ... -- found an access type with designated type "I'Class" defined ... end Factory; ...still illegal, but more interesting. It seems that a Rosen's trick member cannot be initialized because the object's type is more general than the designated access type. It should not be so. A compiler bug? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de