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: a07f3367d7,9dcaa9f073e2ef8f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!q12g2000prb.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 18:11:45 -0700 (PDT) Organization: http://groups.google.com Message-ID: <551ab9c5-f3e8-470d-8d11-4d250b1bb0a0@q12g2000prb.googlegroups.com> References: <9bf2ef73-5cc7-4863-90d7-2e2cf3bcd294@o10g2000prn.googlegroups.com> <92fb5bf2-f43e-4ac9-97eb-6092f10e5607@e17g2000prj.googlegroups.com> <9eddf7db-7f7d-4872-b597-bb0c5bddc50f@x38g2000pri.googlegroups.com> <1e38ede5-7df3-46d5-836e-f48cec87628e@v11g2000prk.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 1308013905 13501 127.0.0.1 (14 Jun 2011 01:11:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 14 Jun 2011 01:11:45 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q12g2000prb.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:20776 Date: 2011-06-13T18:11:45-07:00 List-Id: On Jun 14, 9:08=A0am, Adam Beneschan wrote: > On Jun 13, 5:49=A0pm, Adrian Hoe wrote: > > > > > > > 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 wit= h private; > > > > =A0 =A0type Series_Access =A0 =A0 =A0 =A0 =A0 =A0is new List.Access= _List; > > > > > 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_= String; > > > > =A0 =A0 =A0 =A0 Color =A0 =A0 =A0 =A0 =A0 : in =A0 =A0 Unbounded_St= ring; > > > > =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 = ( Name, 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 arra= y > > > > (1..N) of any_type. This data is then stored in a list. Procedure A= dd > > > > 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 packag= e > > > 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-- Ada= m > > > Yes, you are right. In Heterogeneous_Doubly_Link_List: > > > =A0 =A0type List =A0 =A0 =A0 =A0is limited private; > > =A0 =A0type Access_List is access List; > > > =A0 =A0type Node =A0 =A0 =A0 =A0 =A0 is tagged private; > > =A0 =A0type Access_Node =A0 is access all Node'Class; > > > private > > > =A0 =A0type Node is tagged record > > =A0 =A0 =A0 Previous : Access_Node; > > =A0 =A0 =A0 Next =A0 =A0 : Access_Node; > > =A0 =A0end record; > > > =A0 =A0type List is limited record > > =A0 =A0 =A0 Head =A0 =A0: Access_Node :=3D null; > > =A0 =A0 =A0 Tail =A0 =A0: Access_Node :=3D null; > > =A0 =A0 =A0 Current : Access_Node :=3D null; > > =A0 =A0 =A0 Count =A0 : Unsigned :=3D 0; > > =A0 =A0end record; > > > And: > > > =A0 =A0package body Constructor is > > > =A0 =A0 =A0 function Init > > =A0 =A0 =A0 =A0 =A0( New_Name =A0: Unbounded_String; > > =A0 =A0 =A0 =A0 =A0 =A0New_Color : Unbounded_String; > > =A0 =A0 =A0 =A0 =A0 =A0New_Data =A0: Data_Array ) > > =A0 =A0 =A0 return Element_Record is > > =A0 =A0 =A0 begin > > =A0 =A0 =A0 =A0 =A0return ( List.Constructor.Init > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0with > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Name =A0=3D> New_Name, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Color =3D> New_Color, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Data =A0=3D> New_Data > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ) ; > > =A0 =A0 =A0 end Init; > > > =A0 =A0end Constructor; > > > Is the problem lying in the Data : Data_Array in Element_Record or in > > the return statement of Constructor.Init? > > Where is the above Constructor package defined? =A0Is it directly within > High_Cloud, or is it defined inside a subprogram in the body of > High_Cloud? > > Assuming it's the former, I can't get either our compiler or GNAT > (4.5.2) to generate an error or warning message. =A0However, I don't > know if any relevant rules about accessibility have changed in Ada > 2012. =A0I'd have to study this one further. =A0If you're not using our > compiler or GNAT, and it's an Ada 2005 compiler, it could well be an > error in your compiler. > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Adam Yes, it is directly within High_Cloud. I am using GNATMAKE 4.4.0 20080314 on Mac OS X 10.5.8, Xcode 3.0. -- Adrian Hoe http://adrianhoe.com/adrianhoe