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=-0.2 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:815f:: with SMTP id c92-v6mr4010067iod.22.1526577672024; Thu, 17 May 2018 10:21:12 -0700 (PDT) X-Received: by 2002:a9d:4509:: with SMTP id w9-v6mr207071ote.10.1526577671481; Thu, 17 May 2018 10:21:11 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!85.12.16.70.MISMATCH!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!v8-v6no881844itc.0!news-out.google.com!b185-v6ni1000itb.0!nntp.google.com!v8-v6no881843itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 17 May 2018 10:21:11 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.240.208.23; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 85.240.208.23 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3c1a0e9a-6238-4cf3-b978-f08fd7dd420d@googlegroups.com> Subject: access check failure in "adjust" of a controlled type in aggregate assignement but not with normal variable assignement From: Mehdi Saada <00120260a@gmail.com> Injection-Date: Thu, 17 May 2018 17:21:12 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3786 X-Received-Body-CRC: 1245858874 Xref: reader02.eternal-september.org comp.lang.ada:52396 Date: 2018-05-17T10:21:11-07:00 List-Id: 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: =20 type Matrice_Creuse is new Ada.Finalization.Controlled with record First : Node_Access; Number : Natural :=3D 0; Max_Indices : T_INDICE :=3D (0, 0); end record; type t_indice is record Column, Line=C2=A0: natural=C2=A0; end record; procedure Adjust (Matrice : in out Matrice_Creuse) is begin if Matrice.First =3D null then return; else declare Iter : Node_Access :=3D Matrice.First; Iter_R : Node_Access :=3D new Node'(Iter.all); begin for I in 2 .. Matrice.Number loop pragma Assert (Iter /=3D null); -- useless Iter_R.Next :=3D new Node'(Iter.Next.all); Iter :=3D Iter.Next; -- LINE 61 HEEEEREEE Iter_R :=3D Iter_R.Next; end loop; end; end if; end Adjust; As you can see it SEEMS to work: the code below: Put_Line ("M1"); Put_Line (M1); Put_Line ("M3 initialized to M1 "); Put_Line (M3); M1 :=3D Create_Matrice ((1 =3D> MN ((5, 6), 1))); Put_Line ("M1 modified"); Put_Line(M1); Put_Line ("M3 after modification of M1"); Put_Line (M3); gives: M1 0 0 0 =20 0 0 0 =20 0 0 0 =20 0 0 0 =20 0 8 9 =20 M3 initialized to M1=20 0 0 0 =20 0 0 0 =20 0 0 0 =20 0 0 0 =20 0 8 9 =20 M1 modified 0 0 0 0 0 0 =20 0 0 0 0 0 0 =20 0 0 0 0 0 0 =20 0 0 0 0 0 0 =20 0 0 0 0 0 1 =20 M3 after modification of M1 0 0 0 =20 0 0 0 =20 0 0 0 =20 0 0 0 =20 0 8 9 I verified the figures, the right values are set where they are meant to be= . "Adjust" did work in making a deep copy of M1 into M3. So what's wrong ? It's the "+" function that errs, and exactly this line: R :=3D (Controlled with Number =3D> NumBer_R, MAx_Indices =3D> (Natural'Max= (M1.Max_Indices.Column, M2.Max_Indices.Column), Natural'Max(M1.Max_Indices.= Line, M2.Max_Indices.Line)), FIrst =3D> R.First); Is there something obviously wrong here I don't see ? The entire code is here, if needed: http://depositfiles.com/files/dmizq837v This is the version that fails.