comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: Possible bug?
Date: Fri, 10 Jul 2015 12:06:44 +0200
Date: 2015-07-10T12:06:44+02:00	[thread overview]
Message-ID: <mno5d2$s8e$1@dont-email.me> (raw)
In-Reply-To: <df6857dc-ffca-4468-898b-3bf001a789b6@googlegroups.com>

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

  reply	other threads:[~2015-07-10 10:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10  9:46 Possible bug? Anatoly Chernyshev
2015-07-10 10:06 ` J-P. Rosen [this message]
2015-07-10 22:33   ` Randy Brukardt
2015-07-11  0:29     ` Anatoly Chernyshev
replies disabled

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