From: Mehdi Saada <00120260a@gmail.com>
Subject: "too few element" in an unconstrained array, given as litteral ?
Date: Sat, 20 Jan 2018 02:55:22 -0800 (PST)
Date: 2018-01-20T02:55:22-08:00 [thread overview]
Message-ID: <25736b03-e178-41ce-84fc-0e7da0e11420@googlegroups.com> (raw)
The definitions for polynoms I slightly modified, don't fit anymore wit the test program:
28 Set(Poly3,(2/1, 5/8)); -- but every call on Set does the same
ts_poly1.adb:28:14: warning: too few elements for type "T_Liste_Coef" defined at p_poly_v1_g.ads:48, instance at line 20
ts_poly1.adb:28:14: warning: "Constraint_Error" will be raised at run time
18 package PRat is new P_Rationnels_G(T_Entier);
19 package PRatIO is new PRat.IO;
20 package PPoly is new P_Poly_V1_G(PRat, PRatIO, 40);
_____________________________________
generic
with package P_Rationnels is new P_Rationnels_G(<>);
with package P_Rationnels_io is new P_Rationnels.Io(<>);
Max : Positive;
package PPoly is
_____________________________________
subtype T_Degre is T_Entier range 0..T_Entier(Max); -- I found this phrasing ugly as hell, but I don't know how to make T_Entier visible in the "generic" part since p_rationnels is yet to be instanciated... But I guess it's not the cause of the exception here.
In the test program: Set(Poly3,(2/11)); -- any call of Set raises constraint_error
The current definitions:
type T_Liste_Coef is array (T_Degre range 1..T_Degre'Last) of T_Rationnel;
type T_Vect_Coef is array (T_Degre range <>) of T_Rationnel;
type T_Polynome (Degre : T_Degre := 0) is -- type mutant
record
Coef : T_Vect_Coef (0..Degre) := (others => Nulle);
end record;
And the constructor method: :
procedure Set (
Poly : out T_Polynome;
Vect : in T_Liste_Coef ) is
V_Coef : T_Vect_Coef (0 .. Vect'Last - 1);
begin
for I in Vect'range loop
V_Coef (I - 1) := Vect (I);
end loop;
Poly := (Vect'Length - 1, V_Coef);
end Set;
How can an object of an UNCONSTAINED array type, given as a litteral, have "too few elements ?", though sometime I saw "too few" means "too much", but it wouldn't make more sense to me either.
next reply other threads:[~2018-01-20 10:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-20 10:55 Mehdi Saada [this message]
2018-01-20 12:28 ` "too few element" in an unconstrained array, given as litteral ? Niklas Holsti
2018-01-20 13:21 ` Mehdi Saada
2018-01-20 16:15 ` Niklas Holsti
2018-01-20 16:52 ` Mehdi Saada
2018-01-20 21:27 ` Niklas Holsti
2018-01-20 17:48 ` Why in (array) aggregate, no more component allowed after a dynamic choice ? Mehdi Saada
2018-01-23 0:57 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox