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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,1be082612b8c5f2e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Dynamically tagged expression not allowed. Why? Date: Tue, 1 Jun 2010 18:36:17 -0500 Organization: Jacob Sparre Andersen Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1275435380 3592 69.95.181.76 (1 Jun 2010 23:36:20 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 1 Jun 2010 23:36:20 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news2.google.com comp.lang.ada:12184 Date: 2010-06-01T18:36:17-05:00 List-Id: "Marc A. Criley" wrote in message news:c2ead$4c0150a0$4ca4a823$11809@API-DIGITAL.COM... ... > Stripping out a test case, I see that it has nothing to with the C++ > binding per se, but it's an Ada issue that's flummoxing me. Here's the > test code: > > procedure Dyty_Test is > > type Class_Type is tagged limited record > null; > end record; > > function New_Class_Instance return Class_Type'Class; > > Conn : Class_Type := New_Class_Instance; This is illegal because the function returns a class-wide object and you are assigning it into an object of a specific type. You have to explicitly use a type conversion here: Conn : Class_Type := Class_Type (New_Class_Instance); to specify that you want to truncate the returned object, or make the object classwide: Conn : Class_Type'Class := New_Class_Instance; But notice that while both of these are legal, they'll both raise Program_Error because an access-before-elaboration error (the body of New_Class_Instance hasn't been elaborated at the point of this call). Randy.