comp.lang.ada
 help / color / mirror / Atom feed
From: gerrshapovalov@gmail.com
Subject: yes another gnat bug (inherited tagged type as record field is too much for gnat??)
Date: Fri, 22 Nov 2019 05:26:51 -0800 (PST)
Date: 2019-11-22T05:26:51-08:00	[thread overview]
Message-ID: <9bee64ac-42c4-495e-9ce6-69c306b8e3a5@googlegroups.com> (raw)

Hello,

This bug gets triggered while trying to use a tiny "list library", that provides a uniform interface for an indexed/iterable storage a-la Ada.Containers.Vectors, that can be implemented in various ways: using A.C.Vecotrs internally or even plain "fixed" or "bounded" arrays..

This "library" is a part of ada_composition demo, now made into a stnandalone library, with tests as separate package, and can be found here:
https://github.com/gerr135/ada_composition

The lib itself is under ada_lists
and tests for the lib are under ada_lists_tests


Everything works just fine,.. - as long as I use these lists as "plain variables". However when such list is uses as a record field, gnat just commits suicide trying to compile it. 

Basically:

with Lists.Fixed;

package PL  is new Lists(Natural, Positive);
package PLF is new PL.Fixed;

LS : PLF.List(5);

type FRec (N : Positive) is record
    f : PLF.List(N);
end record;

LC : FRec(5);


LS(1)   := 1; -- works fine
LC.f(1) := 1; -- triggers gnat bug

+===========================GNAT BUG DETECTED==============================+
| Community 2019 (20190517-83) (x86_64-pc-linux-gnu) Storage_Error stack overflow or erroneous memory access

The code in the "library" is pretty much minimal (needed to implements indexed access and iteration), and the tests are just repeated blocks or basic code to test assignment and iteration (in the form of indexed and of loops).

So, the easiest way to reproduce this should be to just clone the project mentioned above ( https://github.com/gerr135/ada_composition )
and then:
cd ada_lists_tests
make

Quite "weirdly" the stock A.C.Vectors work fine as record fields. However, is this due to
1. them being "proper" types rather than descendants of some interface
2. some ACT black magic in their implementation (they do use locks and Unrestricted_Access) in the corresponding bodies, I looked)
is not quite clear to me..

Am I overlooking something here? 
This should be a really common use case, a very basic composition idea:
1. do all the algorithmic stuff at the "higher level", using abstract data accessor methods
2. Defer data storage and other implementation details to child packages..

Yes every time I am trying to do a very basic separation of this kind I trigger yet another gnat bug :(.

             reply	other threads:[~2019-11-22 13:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 13:26 gerrshapovalov [this message]
2019-11-22 13:33 ` yes another gnat bug (inherited tagged type as record field is too much for gnat??) gerrshapovalov
2019-11-22 13:39 ` Simon Wright
2019-11-22 13:57   ` gerrshapovalov
2019-11-25 19:31     ` gerrshapovalov
2019-11-25 20:01       ` Per Sandberg
2019-11-26 13:49         ` gerrshapovalov
2019-11-26 16:09           ` joakimds
2019-11-26 17:09             ` gerrshapovalov
2019-11-26 18:01           ` Simon Wright
2019-12-02  9:02 ` George Shapovalov
2019-12-02 10:02   ` joakimds
2019-12-02 17:12   ` Optikos
2019-12-02 17:50     ` AdaMagica
2019-12-02 19:51     ` George Shapovalov
2019-12-02 20:18       ` Simon Wright
2019-12-02 21:02       ` Optikos
2019-12-09 13:44         ` charlet
2019-12-10 12:12           ` charlet
replies disabled

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