From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Empty String confusion; Positive and Natural Date: Tue, 30 Nov 2021 11:00:11 +0100 Organization: A noiseless patient Spider Message-ID: References: <053c8a45-2829-4f2e-925c-b72308c1fe61n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 30 Nov 2021 10:00:13 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="e84dcf9151b9b5bb6beb5722472b0fe1"; logging-data="28972"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9IIX7IiBzsfjh9QDuy9h6g7dTIysZfH4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Cancel-Lock: sha1:zNIO3jvOQQyfFqz+DL98O89w6h0= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63170 List-Id: On 2021-11-29 23:50, Kevin Chadwick wrote: > > Hopefully I will have a doh moment when I get into the office in the morning and post code. I am getting a range check exception when I assign "" to a standard.String in a record by returning the record from a function. Surely, I must have caused it somehow. It sounds as if you think type String is magic. String is a one-dimensional array type, no different than any other one-dimensional array type. It is declared in ARM A.1(37/3) (http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-1.html) as type String is array(Positive range <>) of Character with Pack; If you think that type T is array (Positive range <>) of Integer; V : T (1 .. 5); ... V := (1 .. 0 => <>); should work, then you don't understand arrays in Ada. If you understand why that won't work, then S : String (1 .. 5); ... S := ""; is the exact same thing and fails in the same way for the same reason. -- Jeff Carter "I did not rob a bank. If I'd robbed a bank, everything would be great. I tried to rob a bank, is what happened, and they got me. I misspelled the note." Take the Money and Run 140