comp.lang.ada
 help / color / mirror / Atom feed
From: mockturtle <framefritti@gmail.com>
Subject: Re: Strange compile-time error with Ada.Containers.Indefinite_Hashed_Maps
Date: Mon, 19 May 2014 09:00:34 -0700 (PDT)
Date: 2014-05-19T09:00:34-07:00	[thread overview]
Message-ID: <40abaf9f-39fd-41c6-9d04-48e37f30d5a9@googlegroups.com> (raw)
In-Reply-To: <lytx8l5152.fsf@pushface.org>

On Monday, May 19, 2014 3:49:45 PM UTC+2, Simon Wright wrote:
> mockturtle <framefritti@gmail.com> writes:
> 
> 
> 
> > When I try to compile the body of the symbol table package I get in
> > the .ads the error
> 
> >     instantiation error at a-cihama.adb:1043
> >     invalid constraint: type has no discriminant
> 
> 
> 
> All of GNAT GPL 2013, FSF GCC 4.8.1 and FSF GCC 4.9.0 are happy with
> your code.
> 

Strange...  

I tried my code on my PC at work; I have the same version of GNAT installed also on my PCs at home.  I'll try there.

> 
> 
> a-cihama.adb (Ada.Containers.Indefinite_Hashed_Maps) line 1043 is in
> Read_Node:
> 
> 
>    function Read_Node
>      (Stream : not null access Root_Stream_Type'Class) return Node_Access
>    is
>       Node : Node_Access := new Node_Type;
>    begin
>       begin
>          Node.Key := new Key_Type'(Key_Type'Input (Stream)); <<<<<<
> 
> and I don't see why GNAT thinks there (should be?) a discriminant there.
> 

I do not see it either... Nevertheless, I just c'n'p-ed the error message. 

This makes me think: could it be some problem with my installation?  Maybe some funny interaction with an older version?

[[ 

My setup is a bit peculiar: I have GNAT installed under /usr/gnat which is actually a symbolic link to /usr/gnat-2014-05-15.  When I install a new version of GNAT, I create a new directory under /usr and move the link of /usr/gnat to the new version.  In this way, I can keep the old version(s) (if something goes wrong I can go back to the old setup), while avoiding (I hope) mix-up between versions.  

]] 

> 
> 
> Is there a reason why you don't make Name_Type just String? You're
> forced to use indefinite hashed maps, so the stored Key is assumed to be
> indefinite and will be allocated. (I tried this and the compiler was
> happy).

Yes, there are few reasons for using a bounded string.  Basically, in other parts of the code it is more convenient (but not strictly necessary) to have a definite type for Type_Name.  Currently I solved the problem by making a "home-brew" version of Indefinite_Hashed_Maps by storing the access to the descriptor.   The change were just minimal.  The curiosity, however, remains.

Riccardo


  reply	other threads:[~2014-05-19 16:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 10:10 Strange compile-time error with Ada.Containers.Indefinite_Hashed_Maps mockturtle
2014-05-19 13:49 ` Simon Wright
2014-05-19 16:00   ` mockturtle [this message]
2014-05-19 16:19     ` G.B.
2014-05-19 16:35     ` Simon Wright
2014-05-19 21:27     ` J-P. Rosen
2014-05-20  6:30       ` Simon Wright
2014-05-20 20:47       ` björn lundin
2014-05-21  5:04         ` J-P. Rosen
2014-05-25 18:28           ` björn lundin
2014-05-26  8:53             ` J-P. Rosen
replies disabled

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