comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: access check failure in "adjust" of a controlled type in aggregate assignement but not with normal variable assignement
Date: Thu, 17 May 2018 21:48:40 +0300
Date: 2018-05-17T21:48:40+03:00	[thread overview]
Message-ID: <fm6149Fpr81U1@mid.individual.net> (raw)
In-Reply-To: <3c1a0e9a-6238-4cf3-b978-f08fd7dd420d@googlegroups.com>

On 18-05-17 20:21 , Mehdi Saada wrote:
> I used controlled type to implement deep copy of lists, but I get
> raised PROGRAM_ERROR : adjust/finalize raised CONSTRAINT_ERROR: essai2.adb:61 access check failed
>
> The definitions:
> type Matrice_Creuse is new Ada.Finalization.Controlled with record
> 	 First       : Node_Access;
> 	 Number      : Natural := 0;
> 	 Max_Indices : T_INDICE := (0, 0);
>       end record;
> type t_indice is record
>  	Column, Line : natural ;
> end record;
>  procedure Adjust (Matrice : in out Matrice_Creuse) is
>       begin
> 	 if Matrice.First = null then return;
> 	 else
> 	    declare
> 	       Iter   : Node_Access := Matrice.First;
> 	       Iter_R : Node_Access := new Node'(Iter.all);
> 	    begin
> 	       for I in 2 .. Matrice.Number loop
> 		  pragma Assert (Iter /= null); -- useless
> 		  Iter_R.Next := new Node'(Iter.Next.all);
> 		  Iter := Iter.Next; -- LINE 61 HEEEEREEE
> 		  Iter_R := Iter_R.Next;
> 	       end loop;
> 	    end;
> 	 end if;
>       end Adjust;

Your Adjust never reassigns Matrice.First, so it continues to refer to 
the original list, not to the new deep copy.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  reply	other threads:[~2018-05-17 18:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17 17:21 access check failure in "adjust" of a controlled type in aggregate assignement but not with normal variable assignement Mehdi Saada
2018-05-17 18:48 ` Niklas Holsti [this message]
2018-05-17 22:38   ` Mehdi Saada
2018-05-18  0:13     ` Mehdi Saada
replies disabled

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