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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9dcaa9f073e2ef8f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!x38g2000pri.googlegroups.com!not-for-mail From: Adrian Hoe Newsgroups: comp.lang.ada Subject: Re: Type in allocator has deeper level than designated class-wide type Date: Mon, 13 Jun 2011 17:49:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9eddf7db-7f7d-4872-b597-bb0c5bddc50f@x38g2000pri.googlegroups.com> References: <9bf2ef73-5cc7-4863-90d7-2e2cf3bcd294@o10g2000prn.googlegroups.com> <92fb5bf2-f43e-4ac9-97eb-6092f10e5607@e17g2000prj.googlegroups.com> NNTP-Posting-Host: 110.159.15.203 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1308012560 32087 127.0.0.1 (14 Jun 2011 00:49:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 14 Jun 2011 00:49:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x38g2000pri.googlegroups.com; posting-host=110.159.15.203; posting-account=coq9PAkAAAB2Xx46RZLFJw5dY9DVXW4- User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUARLECNK X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:20773 Date: 2011-06-13T17:49:19-07:00 List-Id: On Jun 14, 1:11=A0am, Adam Beneschan wrote: > On Jun 13, 8:31=A0am, Adrian Hoe wrote: > > > > > > > Hi all, > > > I have stomped into above error and I am stuck with the error and > > runtime exception PROGRAM_ERROR : accessibility check failed. > > > Here's the fragment of my codes: > > > generic > > =A0 =A0N : Positive; > > =A0 =A0type Item is private; > > package High_Cloud is > > > =A0 =A0package List renames Heterogeneous_Doubly_Link_List; > > =A0 =A0use List; > > > =A0 =A0type Data_Array =A0 =A0 =A0 =A0 =A0 =A0 =A0 is array ( 1 .. N ) = of Item; > > > =A0 =A0type Element_Record =A0 =A0 =A0 =A0 =A0 is new List.Node with pr= ivate; > > =A0 =A0type Series_Access =A0 =A0 =A0 =A0 =A0 =A0is new List.Access_Lis= t; > > > private > > > =A0 =A0type Element_Record is new List.Node with > > =A0 =A0 =A0 record > > =A0 =A0 =A0 =A0 =A0Name =A0 =A0 =A0 =A0 =A0 : Unbounded_String; > > =A0 =A0 =A0 =A0 =A0Color =A0 =A0 =A0 =A0 =A0: Unbounded_String; > > =A0 =A0 =A0 =A0 =A0Data =A0 =A0 =A0 =A0 =A0 : Data_Array; > > =A0 =A0 =A0 end record; > > > ... > > end High_Cloud; > > > In the package body of High_Cloud, I have a procedure: > > > =A0 =A0procedure Add > > =A0 =A0 =A0 ( Cloud =A0 =A0 =A0 =A0 =A0: in out High_Cloud_Record; > > =A0 =A0 =A0 =A0 Name =A0 =A0 =A0 =A0 =A0 =A0: in =A0 =A0 Unbounded_Stri= ng; > > =A0 =A0 =A0 =A0 Color =A0 =A0 =A0 =A0 =A0 : in =A0 =A0 Unbounded_String= ; > > =A0 =A0 =A0 =A0 Data =A0 =A0 =A0 =A0 =A0 =A0: in =A0 =A0 Data_Array ) > > =A0 =A0is > > > =A0 =A0 =A0 New_Element : List.Access_Node; > > > =A0 =A0begin > > > =A0 =A0 =A0 New_Element :=3D new Element_Record' > > <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Error/Warning here. > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( Constructor.Init ( Na= me, Color, Data) ) ; > > > =A0 =A0 =A0 Concatenate ( Cloud.Series, New_Element ) ; > > > =A0 =A0end Add; > > > My intention is to use genericity to create a data which is an array > > (1..N) of any_type. This data is then stored in a list. Procedure Add > > instantiate (by calling to Constructor.Init) the list's node with > > data. > > > I have read the ARM 3.10.2 and 3.10.1 and also John Barnes book yet I > > still have no clue how to solve the problem. > > > Can you please help? Thanks. > > I think we need to see the definition of Constructor.Init, at least. > (I'm guessing that Heterogeneous_Doubly_Link_List is a library package > that defines Node as a tagged record and Access_Node as "access all > Node'Class". =A0But I don't have a guess about what Init is.) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Adam Yes, you are right. In Heterogeneous_Doubly_Link_List: type List is limited private; type Access_List is access List; type Node is tagged private; type Access_Node is access all Node'Class; private type Node is tagged record Previous : Access_Node; Next : Access_Node; end record; type List is limited record Head : Access_Node :=3D null; Tail : Access_Node :=3D null; Current : Access_Node :=3D null; Count : Unsigned :=3D 0; end record; And: package body Constructor is function Init ( New_Name : Unbounded_String; New_Color : Unbounded_String; New_Data : Data_Array ) return Element_Record is begin return ( List.Constructor.Init with Name =3D> New_Name, Color =3D> New_Color, Data =3D> New_Data ) ; end Init; end Constructor; Is the problem lying in the Data : Data_Array in Element_Record or in the return statement of Constructor.Init?