comp.lang.ada
 help / color / mirror / Atom feed
From: Egil H H <ehh.public@gmail.com>
Subject: Re: CONSTRAINT ERROR: erroneous memory access
Date: Sun, 7 Jun 2020 01:00:04 -0700 (PDT)
Date: 2020-06-07T01:00:04-07:00	[thread overview]
Message-ID: <968e2a27-e3a4-4199-97c2-5ad0a2e4facdo@googlegroups.com> (raw)
In-Reply-To: <d0ff83ad-a216-4fd6-b0ff-ef51a7c27d48o@googlegroups.com>

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 95 back when I was working for a defense contractor. But, now that I'm retired, 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 from A.18.31, pages 574-576). But, when I read in the data and call the Shortest_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 (or NOT doing) wrong. 
>


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 Natural, resulting in a huge stack allocation.

If you instead move the instantiation of SP (and the Display procedures, which depends on the instantiation) to after the declaration of the subtype Vertex, and then use that subtype as Node instead of Natural, the stack allocation will be reduced significantly.

  reply	other threads:[~2020-06-07  8:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-06 23:40 CONSTRAINT ERROR: erroneous memory access jcupak
2020-06-07  8:00 ` Egil H H [this message]
2020-06-09  0:39   ` CONSTRAINT ERROR: erroneous memory access - SOLVED John Cupak
2020-06-09 10:07     ` AdaMagica
2020-06-07  8:51 ` CONSTRAINT ERROR: erroneous memory access Jeffrey R. Carter
2020-06-07 10:20   ` Simon Wright
2020-06-07 14:47     ` Jeffrey R. Carter
2020-06-07 15:53 ` Anh Vo
2020-06-07 16:17   ` Egil H H
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox