From: howard@hulder.css.gov (Howard Turner)
Subject: Re: What should this do?
Date: 28 Jun 91 21:40:23 GMT [thread overview]
Message-ID: <758@esosun.UUCP> (raw)
In-Reply-To: dlindsle@afit.af.mil (David T. Lindsley)
dlindsle@afit.af.mil (David T. Lindsley) writes:
I have a question about dynamic strings. I was looking at a package
on simtel20 that did the following:
subtype INDEX is natural range 0..100;
type DYN_STRING (SIZE : INDEX := 0) is private;
-- private
-- type DYN_STRING (size : index := 0) is
-- record
-- DATA : string (1..size);
-- end record;
the second declaration had a note to the effect of "uncomment and use
this if you've got a VALIDATED compiler".
Now as far as I can tell, during elaboration, a declaration of the form
S : DYN_STRING;
will result in the attempt to allocate an array constrained to (1..0),
which should raise an exception. At least, that's what it does under
VAX Ada, but not on Verdix. (Both generate warnings.)
It seems to me this has to be a bug in one of the compilers. My question
is: whose? Should this, or should it not, raise an exception? (The
LRM references weren't any help.)
Ahemm...
While working on a recent project, I ran into much the same problem.
One of the persons involved (Bob Smith, smith@prc.unisys.com) found
the following and sent it to me. Bob set me right. Thanks Bob.
Bob Smith (quite a while ago) writes:
...
You might try reading LRM 3.6.1 paragraph 4:
If any of the discrete ranges defines a null range, any array thus
constrained is a null array, having no components.
Then take a look at 3.5 paragraph 3:
The range L .. R specifies the values from L to R inclusive if the
relation L <= R is true. . . . A null range is a range for which
the relation R < L is TRUE; no value belongs to a null range.
...
While it does not explicitly mention strings, remember that the type
string is defined as an array of characters.
Hopes this helps
Howard Turner
SAIC
619.458.2654
howard@esosun.css.gov
next prev parent reply other threads:[~1991-06-28 21:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-06-28 19:35 What should this do? David T. Lindsley
1991-06-28 21:40 ` Howard Turner [this message]
1991-06-29 0:31 ` Jim Showalter
1991-06-29 16:44 ` Michael Feldman
1991-06-29 21:22 ` Jim Showalter
1991-06-29 5:52 ` rharwood
-- strict thread matches above, loose matches on Subject: below --
1991-07-01 12:45 CBW Consulting
1991-07-01 15:21 voder!wlbr!lonex.radc.af.mil!blackbird.afit.af.mil!dlindsle
1991-07-02 13:06 Fred Stluka
1991-07-02 17:09 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!petunia!nwebre
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox