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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7d1f3e726c03ea8,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-23 04:31:50 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dromy@isdn.net.il (Uri) Newsgroups: comp.lang.ada Subject: constraint error with tagged type Date: 23 Feb 2003 04:31:50 -0800 Organization: http://groups.google.com/ Message-ID: <5e59165b.0302230431.2a482db7@posting.google.com> NNTP-Posting-Host: 212.179.128.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1046003510 7491 127.0.0.1 (23 Feb 2003 12:31:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 23 Feb 2003 12:31:50 GMT Xref: archiver1.google.com comp.lang.ada:34469 Date: 2003-02-23T12:31:50+00:00 List-Id: Hello, I am trying to write a program that create polygons I created a package called 'shapes': -- shapes.ads package shapes is type point is record X, Y : float; end record; type shape is abstract tagged null record; ... some function dealing with shape ... type shape_ptr is access all shape'CLASS; type Polygon_Points is array (integer range <>) of point; type polygon(Edges : integer) is new shape with record vertex : Polygon_Points (1..Edges); end record; type polygon_ptr is access all polygon'CLASS; ... some function dealing with polygon ... function make_polygon(Point_Array : Polygon_Points) return polygon_ptr; procedure put_values (poly : out polygon; Pt_Array : Polygon_Points); private ... some private function ... end shapes; -------------------------------------------------------------------------------- -- shapes.adb package body shapes is ... some finctions ... function make_polygon(Point_Array : Polygon_Points) return polygon_ptr is -- create a polygon This_Shape : polygon_ptr := new polygon(Point_Array'LENGTH); begin put_values(This_Shape.all, Point_Array); return This_Shape; end make_polygon; procedure put_values (poly : out polygon; Pt_Array : Polygon_Points) is -- put values in a polygon begin for I in Pt_Array'RANGE loop poly.vertex(I) := Pt_Array(I); end loop; end put_values; end shapes; I tried to create a polygon in my main program: -- main.adb with shapes; use shapes; procedure main is shape_array : array (1..4) of shape_ptr; begin -- create a polygon ... blah, blah, blah ... shape_array(3) := shape_ptr(make_polygon (((0.0, 0.0), (0.0, 3.0), (4.0, 0.0), (4.0, 3.0)))); ... blah, blah, blah ... end main; but when I ran it I got a CONTRAINT_ERROR, while using the debuger I got something that looks like ____gant_malloc, but I don't understad why the program can't create an array of points with only 4 members. Please tell me what I did wrong.