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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.47.241 with SMTP id b46mr15583460otd.40.1467000006349; Sun, 26 Jun 2016 21:00:06 -0700 (PDT) X-Received: by 10.157.34.202 with SMTP id y68mr583535ota.4.1467000006316; Sun, 26 Jun 2016 21:00:06 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!jk6no3498813igb.0!news-out.google.com!d62ni19971ith.0!nntp.google.com!jk6no3498806igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 26 Jun 2016 21:00:05 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8202:8510:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8202:8510:5985:2c17:9409:aa9c References: <57346ac8$0$4570$426a74cc@news.free.fr> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada.Strings.Fixed.Count raises Storage_Error From: rieachus@comcast.net Injection-Date: Mon, 27 Jun 2016 04:00:06 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:30952 Date: 2016-06-26T21:00:05-07:00 List-Id: On Sunday, June 26, 2016 at 8:21:29 PM UTC-4, Jeffrey R. Carter wrote: =20 > 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' live= s > miserable: >=20 > while Ind <=3D Source'Last loop > if Pattern =3D Source (Ind .. Ind) then > ... > else > Ind :=3D Ind + 1; > end if; > end loop; >=20 > Add >=20 > exit when Ind =3D Integer'Last; >=20 > after "else". I see no reason this code shouldn't correctly handle this c= orner case. It is not a one-line change. There is documentation, adding cases to regre= ssion test libraries, and finally the effort on the developer's part to fix= this without producing significantly slower code. How many times will tha= t extra line be executed if the string is large, but does not end at Intege= r'Last? This is extremely important since it is a branch in an innermost l= oop. If I were responsible for fixing this I would hoist the case of strin= gs with S'Last =3D Integer'Last up as high as possible, even if it required= (almost) duplicating a lot of code. This tradeoff between performance and corner cases has been made before. T= ry writing a loop that runs from X to Y for some non-static values, then te= st the code when X =3D Integer'First and Y =3D Integer'Last. You may want = to print a period for each 100 million times around the loop... Do the same thing for a large unsigned array with static bounds of U'First = and and U'Last. This case should work as expected. Why? Because looping = over the entire range of an unsigned type is something that occurs often in= radar, hash tables, and other cases. On a 64-bit machine it probably will = not exit if you have the largest possible unsigned type, though I don't kno= w how you could tell. (Even if you could do each interation in a nanosecond= , that would take over 500 years...)