comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: error in index constraints with initial value
Date: Thu, 4 Apr 2002 12:41:36 -0500
Date: 2002-04-04T17:41:37+00:00	[thread overview]
Message-ID: <a8i38h$1ts$1@nh.pace.co.uk> (raw)
In-Reply-To: 21b0043b.0204040925.4654c421@posting.google.com

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" <thomas_haeckel@web.de> 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





  reply	other threads:[~2002-04-04 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-04 17:25 error in index constraints with initial value Thomas Haeckel
2002-04-04 17:41 ` Marin David Condic [this message]
2002-04-04 17:48 ` Toshitaka Kumano
2002-04-04 20:19 ` Frank J. Lhota
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox