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 X-Received: by 2002:ac8:120a:: with SMTP id x10mr4708007qti.298.1572514230574; Thu, 31 Oct 2019 02:30:30 -0700 (PDT) X-Received: by 2002:a9d:7c8:: with SMTP id 66mr1192123oto.147.1572514230258; Thu, 31 Oct 2019 02:30:30 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!j16no6593033qtl.0!news-out.google.com!g53ni35qtg.0!nntp.google.com!j16no6593023qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 31 Oct 2019 02:30:29 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=136.163.208.2; posting-account=HFCrOQoAAABZD_f-UUbYHm3lJDIrh-UX NNTP-Posting-Host: 136.163.208.2 References: <5d710dac-d172-4a31-899e-1bf95e220ed6@googlegroups.com> <7fb6d1d0-18df-43b9-bcdc-9782dfb5171c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <22cb257e-36af-42e6-b969-ed22bd7ae3a6@googlegroups.com> Subject: Re: gnat.string_split , howto manipulate slice numbers From: joakimds@kth.se Injection-Date: Thu, 31 Oct 2019 09:30:30 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57396 Date: 2019-10-31T02:30:29-07:00 List-Id: > > > > Another reason is to distinguish index/key from position. When both > > are subtypes of integer some bugs may slip through, e.g. > > > > A (A'Length - 1) > > > > This is broken code, but the compiler cannot detect it. > > How is it broken? > The index should be an index from A'First to A'Last and using A'Length does not guarantee A'Length - 1 being a valid index. Hmm... how to fix it in the best possible way? Or just accept it being an edge case Ada does not detect at compile-time? Best regards, Joakim