comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Warning: Storage error
Date: Sat, 09 Aug 2014 09:08:54 -0700
Date: 2014-08-09T09:08:54-07:00	[thread overview]
Message-ID: <ls5h2m$11p$2@dont-email.me> (raw)
In-Reply-To: <ls5e8r$373$1@speranza.aioe.org>

On 08/09/2014 08:20 AM, Victor Porton wrote:
>     type My_String (Length: Integer := 0) is
>        record
>           Str: String(1..Length);
>        end record;
>
> warning: creation of "My_String" object may raise Storage_Error
>
> Why this warning?

There are 2 ways to implement such a type. One allocates just as much space as 
the current value (plus some small fixed overhead); the other allocates enough 
space for the largest value.

Some argue that Ichbiah intended the former, and there is at least one compiler 
that does it that way. It appears that you're using a compiler that uses the 
latter, and every such object will take at least Integer'Last bytes.

It also appears that you're attempting to reinvent Ada.Strings.Bounded.

-- 
Jeff Carter
"Insufficient laughter--that's grounds for divorce."
Play It Again, Sam
126

  parent reply	other threads:[~2014-08-09 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-09 15:20 Warning: Storage error Victor Porton
2014-08-09 16:07 ` anon
2014-08-09 16:08 ` Jeffrey Carter [this message]
2014-08-09 16:26   ` Dmitry A. Kazakov
2014-08-09 16:46     ` Jeffrey Carter
2014-08-09 16:57       ` Dmitry A. Kazakov
2014-08-09 16:21 ` Dmitry A. Kazakov
replies disabled

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