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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8e97b70a5f7d5495 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Wed, 28 Feb 2007 18:14:47 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Brain bug or GNAT bug? References: Date: Thu, 01 Mar 2007 01:11:38 +0100 Message-ID: <87irdlx1ol.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:yzvNzXIzc3MQMM8xdzZu7l/3NUc= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.209.40 X-Trace: sv3-0idARK+qTEnleMKbuNV5BSYQOE/uHJgXUoHWpXzMYHmfc0rNKCQiRrEnTtqGYBXRoqobiIjqYG4NdPC!2AIG/uY3aBT77bGkuYU5ESt0kx+VWTn3FT1uCEvTkAHqvtL5evIKP9zBlYCaXrb7CNe/CoChig== X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Xref: g2news2.google.com comp.lang.ada:9610 Date: 2007-03-01T01:11:38+01:00 List-Id: "(see below)" writes: > Using GNAT GPL 2006 (PPC/Darwin), I instantiate: > > generic > > type modular is mod <>; > > package try is > > type DT1 (the_size : modular) is limited private; > > -- subtype bounded is modular; > subtype bounded is modular range 1..9; > type DT2 (the_size : bounded) is limited private; > -- | > -- >>> subtype must be compatible with parent discriminant > > function is_empty (the_data : DT2) return Boolean; > > private > > type a_thing is null record; > type a_ptr is access a_thing; > > type a_ptr_array is array (modular range <>) of a_ptr; > > type DT1 (the_size : modular) is > record > things : a_ptr_array (1 .. the_size); > end record; > > type DT2 (the_size : bounded) is new DT1(the_size); > > end try; > > and I get the error message commented-out at line 11. > > If I substitute the declaration at line 9 for that at line 10, > the test program compiles and runs correctly. > > Am I blundering here, or is this a GNAT bug? Per ARM 3.7(15), the types of DT1.the_size and DT2.the_size must be statically compatible. In other words, you must guarantee at compile time that "the_size" is in the range of type "modular". Because modular's range is not known at compile time but bounded's is, no such guarantee exists. If you remove the "range" constraint on subtype "bounded", then the range for "bounded" and the range of "modular" are known at compile time to be identical, so all is well. What are ou trying to achieve? -- Ludovic Brenta.