comp.lang.ada
 help / color / mirror / Atom feed
From: mockturtle <framefritti@gmail.com>
Subject: Funny (so to say...) interaction of "not null" and Vectors?
Date: Tue, 8 Oct 2019 08:46:51 -0700 (PDT)
Date: 2019-10-08T08:46:51-07:00	[thread overview]
Message-ID: <3113a338-c9fd-4c9e-8197-9aca91d2b1d5@googlegroups.com> (raw)

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 
     Acc : Class_Access;  -- This forces me to initialize it
  end record; 

package Vec is new Ada.Containers.Vectors(Positive, Rec);  
-- 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 failed."  By looking into the GNAT implementation, I see that the Vector is implemented 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 entry.  My suspect is that the dynamically created array can have some null access value, causing the error.

Does this make any sense?  If yes, I'll remove the "not null" requirement.

Thank you in advance 

Riccardo 

             reply	other threads:[~2019-10-08 15:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 15:46 mockturtle [this message]
2019-10-08 16:01 ` Funny (so to say...) interaction of "not null" and Vectors? mockturtle
2019-10-08 16:24   ` J-P. Rosen
2019-10-08 17:38     ` mockturtle
2019-10-09 18:58       ` mockturtle
2019-10-08 16:21 ` Dmitry A. Kazakov
2019-10-08 17:30   ` mockturtle
replies disabled

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