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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Possible bug? Date: Fri, 10 Jul 2015 12:06:44 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 10 Jul 2015 10:05:22 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="23dab0694e4174fdc880833ec67fa650"; logging-data="28942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kqrljuTFdWAZxC6m6m+LN" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: Cancel-Lock: sha1:IvofH3uf2qsru0w4xnF/5URZi4Q= Xref: news.eternal-september.org comp.lang.ada:26737 Date: 2015-07-10T12:06:44+02:00 List-Id: Le 10/07/2015 11:46, Anatoly Chernyshev a écrit : > procedure fail_arr is > n_d,n_f: constant integer:=10; > type tss is array (1..n_d,1..n_f) of float; > tser:tss:=(others=>(0.0,0.0)); > begin > for i in tser'range(1) loop > for j in tser'range(2) loop > tser(i,j):=0.0; > end loop; > end loop; > end fail_arr; > > From my understanding, in the declaration of tser, its first two > columns must be populated with 0.0, and the rest is to be left > uninitialized. If that's what you want, you have to say so: > tser:tss:=(others=>(0.0,0.0, others => <>)); > But under no circumstances shall the array to have > dimensions (n_d, 2). But that's exactly what happens in the program. > > The compiler even gives me nice soft warning about this: > > 4:11 warning: too few elements for type "tss" defined at line 3 4:11 > warning: "Constraint_Error" will be raised at run time > > Even though it should abort the compilation with an error message. > No? > No. What happens is that it constructs an initialization aggregate whose bounds are (n_d, 2), and then raises Constraint_Error because the bounds of the initial value do not match those of the variable. That's exactly what the warning is telling you. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr