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:4a8e:: with SMTP id x136mr30402200qka.370.1570549612235; Tue, 08 Oct 2019 08:46:52 -0700 (PDT) X-Received: by 2002:a9d:5c88:: with SMTP id a8mr18108668oti.276.1570549611963; Tue, 08 Oct 2019 08:46:51 -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!o24no8902081qtl.0!news-out.google.com!q23ni370qtl.1!nntp.google.com!o24no8902069qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 8 Oct 2019 08:46:51 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=158.110.243.26; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 158.110.243.26 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3113a338-c9fd-4c9e-8197-9aca91d2b1d5@googlegroups.com> Subject: Funny (so to say...) interaction of "not null" and Vectors? From: mockturtle Injection-Date: Tue, 08 Oct 2019 15:46:52 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57261 Date: 2019-10-08T08:46:51-07:00 List-Id: Dear.all, I am getting crazy over a mysterious bug (that gives mysterious exceptions)= that seems to boil down to an interaction between "not null" specification= and vectors. This is an over simplified version of my case. I would like to know if my = hypothesis makes sense. --- BEGIN ---- type Int is interface; type Class_Access is not null access all Int'Class; -- NOTE: not null type Rec is -- A record with a not null component record=20 Acc : Class_Access; -- This forces me to initialize it end record;=20 package Vec is new Ada.Containers.Vectors(Positive, Rec); =20 -- Vectors that have as elements records with a "not null access" field --- END --- It seems that the procedure Append from Vec dies with a "access check faile= d." By looking into the GNAT implementation, I see that the Vector is impl= emented using a dynamically allocated array of Rec (in this case). When I = do Append, the procedure re-allocate the array to make room for the new ent= ry. My suspect is that the dynamically created array can have some null ac= cess value, causing the error. Does this make any sense? If yes, I'll remove the "not null" requirement. Thank you in advance=20 Riccardo=20