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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,be90c35154ae91c1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-04 23:49:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!news-x2.support.nl!psinet-eu-nl!psiuk-p4!uknet!psiuk-p3!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: error in index constraints with initial value Date: Thu, 4 Apr 2002 12:41:36 -0500 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: References: <21b0043b.0204040925.4654c421@posting.google.com> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 1017942097 1980 136.170.200.133 (4 Apr 2002 17:41:37 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 4 Apr 2002 17:41:37 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:22136 Date: 2002-04-04T17:41:37+00:00 List-Id: The problem is likely to be in: 12:XXXX_LINE: VAR_LINE; The GNAT compiler allocates for the worst possible case so that if you assign to XXXX_LINE, it doesn't have to reallocate memory. This is not really so much a feature of Ada95 as it is a feature of GNAT. IIRC, the old DEC Ada83 compiler would not have a problem with this and would do the memory allocation on assignment. Its an implementation decision that is allowable by the standard. You could use an access type to VAR_LINE and the "new" allocator to get around this. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com "Thomas Haeckel" wrote in message news:21b0043b.0204040925.4654c421@posting.google.com... > Hi, > > I've compiled the following procedure with gnat version 2.8.1 and also > 3.14p. > > 1:with Text_IO; use Text_IO; > 2: > 3:procedure Index_Constraint_Test is > 4: > 5:type VAR_LINE(LENGTH:INTEGER:=5) is > 6:record > 7: IMM:STRING(1..LENGTH); > 8:end record; > 9: > 10:NULL_LINE: VAR_LINE(0); > 11:TWO_LINE: VAR_LINE(2); > 12:XXXX_LINE: VAR_LINE; > 13: > 14:begin > 15: Put_Line("NULL_LINE="&NULL_LINE.IMM&"#"); > 16: Put_Line("TWO_LINE="&TWO_LINE.IMM&"#"); > 17: Put_Line("XXXX_LINE="&XXXX_LINE.IMM&"#"); > 18:end; > > I got following runtime error with both gnat versions: > raised STORAGE_ERROR : object too large > This is caused by the variable instantiation XXXX_LINE in line 12. > After the example in LRM 3.6.1(15) this should be allowed. > Also an old Aionix-Ada83-compiler works fine. > Why has the initialization of the index constraint in line 5 no effect > apparently ? > Is this effect a "feature" of gnat or Ada95 ? > How can I do an null-array (length 0, no component) definition at > compile time, to assign an arraysize while runtime ? > > Thanks, > Thomas