comp.lang.ada
 help / color / mirror / Atom feed
* CONSTRAINT ERROR? access check failed
@ 2018-03-01  0:27 Mehdi Saada
  2018-03-01  8:07 ` Niklas Holsti
  2018-03-01  8:30 ` Simon Wright
  0 siblings, 2 replies; 17+ messages in thread
From: Mehdi Saada @ 2018-03-01  0:27 UTC (permalink / raw)


I got
raised CONSTRAINT_ERROR : ledit.adb:34 access check failed
for the "while" line before. I found an old post about this problem, allocated composite object being constrained even when being of an unconstrained subtype... but I hardly understood anything. It's clearly out of my league, and it's not like I don't LOVE to dig and learn, believe me:
  procedure INSERT_OR_REPLACE
     (NUMBER : in LINE_NUMBER; LINE : in STRING) is
      TEMP : access LINK := HEAD;
   begin
      while TEMP.NEXT /= null and TEMP.NEXT.NUM < NUMBER loop
	 TEMP := TEMP.NEXT;
      end loop;
      TEMP.next := new LINK'
           (Num => NUMBER,
	   Length => LINE'Length,
	   NEXT   => (if TEMP.NEXT.NUM = NUMBER then TEMP.NEXT.NEXT else TEMP.NEXT),
	   Line   => LINE);
   end;

So, if someone could provide me a quick solution that don't change much my current code (I already have trouble understanding it, changing the data structure would crush me)... Here's the LINK type and HEAD constant:
type Link (Num : LINE_NUMBER := 0; Length : NATURAL := 0) is
      record
	 NEXT : access LINK := null;
	 Line : String (1 .. Length) := (1..Length => ' ');
      end record;
HEAD   : constant access Link := new LINK '(0,0,null,"");

Instead of a snippet, you could advise me to put assertions here and there to help me see the solution by myself, eventually. But I definitely won't eat the whole damn allocator AARM section...

Mehdi


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-03-01 18:34 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01  0:27 CONSTRAINT ERROR? access check failed Mehdi Saada
2018-03-01  8:07 ` Niklas Holsti
2018-03-01 12:44   ` Mehdi Saada
2018-03-01 13:45     ` Björn Lundin
2018-03-01 14:06   ` Mehdi Saada
2018-03-01 14:31     ` Mehdi Saada
2018-03-01 14:38     ` Mehdi Saada
2018-03-01 15:53       ` Anh Vo
2018-03-01 17:24         ` Mehdi Saada
2018-03-01 18:34           ` Anh Vo
2018-03-01 17:26       ` Simon Wright
2018-03-01 17:47         ` Mehdi Saada
2018-03-01 17:56       ` Jeffrey R. Carter
2018-03-01  8:30 ` Simon Wright
2018-03-01 12:14   ` Mehdi Saada
2018-03-01 13:27     ` Simon Wright
2018-03-01 13:44       ` Mehdi Saada

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