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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Warning: Storage error Date: Sat, 09 Aug 2014 09:08:54 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 9 Aug 2014 16:08:55 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="a0c81a81d1281113b3831cf0c04e791a"; logging-data="1081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/p7FcE5ioeMYjMmKXFc7nFIGodsPXRgww=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: Cancel-Lock: sha1:lgv6hTDU4p/Yq+7WKdVb38NH7+I= Xref: news.eternal-september.org comp.lang.ada:21611 Date: 2014-08-09T09:08:54-07:00 List-Id: 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