comp.lang.ada
 help / color / mirror / Atom feed
From: "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net>
Subject: Re: error in index constraints with initial value
Date: Thu, 04 Apr 2002 20:19:37 GMT
Date: 2002-04-04T20:19:37+00:00	[thread overview]
Message-ID: <tz2r8.2072$8r5.932@nwrddc01.gnilink.net> (raw)
In-Reply-To: 21b0043b.0204040925.4654c421@posting.google.com

The problem with your definition of XXXX_LINE is that you do not constrain
the record variant LENGTH. LENGTH will default to 5, but since it is not
constrained, XXXX_LINE can be assigned a VAR_LINE value of any length, even
LENGTH => Integer'Last! Of course, this requires more space than is
possible, resulting in the blow-up.

There are a couple of ways to handle this properly. If XXXX_LINE really
needs to hold VAR_LINE records of widely varying and arbitrarily long
lengths, you should declare XXXX_LINE as an access value and allocate these
VAR_LINE records from the heap.

Another possible solution is available is we can assume that there is a
reasonable upper limit on the length of a VAR_LINE. We can then use a
subtype to limit the value of LENGTH, so that VAR_LINE has a reasonable
maximum size, e.g.,

    subtype Var_Line_Len is Integer range 0 .. 1023;
    type VAR_LINE( LENGTH : Var_Line_Len := 5 ) is
    record
       IMM:STRING(1..LENGTH);
    end record;

With this declaration, VAR_LINE will never have a length greater than
Var_Line_Len'Last. With this change, your program should compile.






      parent reply	other threads:[~2002-04-04 20:19 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
2002-04-04 17:48 ` Toshitaka Kumano
2002-04-04 20:19 ` Frank J. Lhota [this message]
replies disabled

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