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 10.182.22.133 with SMTP id d5mr16931583obf.27.1400515235374; Mon, 19 May 2014 09:00:35 -0700 (PDT) X-Received: by 10.140.96.41 with SMTP id j38mr85575qge.8.1400515235266; Mon, 19 May 2014 09:00:35 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!c1no10601061igq.0!news-out.google.com!qf4ni2017igc.0!nntp.google.com!c1no10601044igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 19 May 2014 09:00:34 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=158.110.27.77; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 158.110.27.77 References: <9d912199-ff00-403f-b6e3-fb9632ec145e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <40abaf9f-39fd-41c6-9d04-48e37f30d5a9@googlegroups.com> Subject: Re: Strange compile-time error with Ada.Containers.Indefinite_Hashed_Maps From: mockturtle Injection-Date: Mon, 19 May 2014 16:00:35 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 3594 Xref: number.nntp.dca.giganews.com comp.lang.ada:186481 Date: 2014-05-19T09:00:34-07:00 List-Id: On Monday, May 19, 2014 3:49:45 PM UTC+2, Simon Wright wrote: > mockturtle writes: >=20 >=20 >=20 > > When I try to compile the body of the symbol table package I get in > > the .ads the error >=20 > > instantiation error at a-cihama.adb:1043 > > invalid constraint: type has no discriminant >=20 >=20 >=20 > All of GNAT GPL 2013, FSF GCC 4.8.1 and FSF GCC 4.9.0 are happy with > your code. >=20 Strange... =20 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. >=20 >=20 > a-cihama.adb (Ada.Containers.Indefinite_Hashed_Maps) line 1043 is in > Read_Node: >=20 >=20 > function Read_Node > (Stream : not null access Root_Stream_Type'Class) return Node_Access > is > Node : Node_Access :=3D new Node_Type; > begin > begin > Node.Key :=3D new Key_Type'(Key_Type'Input (Stream)); <<<<<< >=20 > and I don't see why GNAT thinks there (should be?) a discriminant there. >=20 I do not see it either... Nevertheless, I just c'n'p-ed the error message.= =20 This makes me think: could it be some problem with my installation? Maybe = some funny interaction with an older version? [[=20 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 ver= sion 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 s= omething goes wrong I can go back to the old setup), while avoiding (I hope= ) mix-up between versions. =20 ]]=20 >=20 >=20 > 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 ha= ve 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 t= he descriptor. The change were just minimal. The curiosity, however, rem= ains. Riccardo