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!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Ada.Strings.Fixed.Count raises Storage_Error Date: Sun, 26 Jun 2016 17:21:25 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <57346ac8$0$4570$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 27 Jun 2016 00:21:28 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="48b46be33beed75863f69afa437f956b"; logging-data="25008"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19E8vSAwtkS85zW1gcehRUo+dYrL6p1CCg=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: Cancel-Lock: sha1:gYEexMErxQKso2iSBvss2mlyHMg= Xref: news.eternal-september.org comp.lang.ada:30950 Date: 2016-06-26T17:21:25-07:00 List-Id: On 06/26/2016 04:23 PM, rieachus@comcast.net wrote: > > How about no one reports this non-existent error? This is a category of > problem that the ARG decided long ago should be considered pathologies. The > original case was a program that checked whether a task returned by a > function was Terminated. (The "correct" answer was True, but the program was > totally useless for anything other than making compiler developers lives > miserable.) > > A string which ends at Integer'Last is either huge enough to raise > Storage_Error anyway, or a clever compiler test that exists only to make > compiler developers lives miserable. I'm retired now, so I can say that > without insulting customers. And as Randy pointed out anything is allowed to > raise Storage_Error. That might not be user friendly, but in this case > (Strings ending at Integer'Last) no sensible user is going to run into the > problem. While I mostly agree, this one, given the code presented earlier, is a 1-line change to correct, which hardly seems like it would make developers' lives miserable: while Ind <= Source'Last loop if Pattern = Source (Ind .. Ind) then ... else Ind := Ind + 1; end if; end loop; Add exit when Ind = Integer'Last; after "else". I see no reason this code shouldn't correctly handle this corner case. -- Jeff Carter "[T]he Musgroves had had the ill fortune of a very troublesome, hopeless son, and the good fortune to lose him before he reached his twentieth year ..." Persuasion 154