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 2002:a37:a995:: with SMTP id s143mr17201211qke.147.1591516804761; Sun, 07 Jun 2020 01:00:04 -0700 (PDT) X-Received: by 2002:a9d:71d6:: with SMTP id z22mr13616333otj.81.1591516804503; Sun, 07 Jun 2020 01:00:04 -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!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 7 Jun 2020 01:00:04 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2a01:799:620:d00:8d71:1a5e:d935:b659; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn NNTP-Posting-Host: 2a01:799:620:d00:8d71:1a5e:d935:b659 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <968e2a27-e3a4-4199-97c2-5ad0a2e4facdo@googlegroups.com> Subject: Re: CONSTRAINT ERROR: erroneous memory access From: Egil H H Injection-Date: Sun, 07 Jun 2020 08:00:04 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:58994 Date: 2020-06-07T01:00:04-07:00 List-Id: On Sunday, June 7, 2020 at 1:40:04 AM UTC+2, jcu...@gmail.com wrote: > It has been a few years since I have written Ada; I used and taught Ada 9= 5 back when I was working for a defense contractor. But, now that I'm retir= ed, I wanted to get up to speed with Ada 2012, so I decided to implement a = main program to see how the Shortest_Paths generic package works (taken fro= m A.18.31, pages 574-576). But, when I read in the data and call the Shorte= st_Path function, it returns with CONSTRAINT ERROR: erroneous memory access= . I've tried multiple times, but can't seem to figure out what I'm doing (o= r NOT doing) wrong.=20 > If you look at the body of Shortest_Path, you'll see multiple declarations = of arrays with Node as the Index type. In your case, Node is of type Natura= l, resulting in a huge stack allocation. If you instead move the instantiation of SP (and the Display procedures, wh= ich depends on the instantiation) to after the declaration of the subtype V= ertex, and then use that subtype as Node instead of Natural, the stack allo= cation will be reduced significantly.