comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: index range while type (seemingly defined) to always include this particular value
Date: Thu, 4 Jan 2018 17:19:27 +0100
Date: 2018-01-04T17:19:27+01:00	[thread overview]
Message-ID: <p2lk6g$5s1$1@dont-email.me> (raw)
In-Reply-To: <a01765b4-0fa2-4fa4-9ebc-d75c6d75a4c3@googlegroups.com>

On 01/04/2018 04:39 PM, Mehdi Saada wrote:
> This line: 	PUT(POLY.COEF(0));
> raises Constraint Error: index check failed. I can't get my head round about this.
> Each time the function
> See below: 0 is ALWAYS in the index range of COEF, which is an array component.
> 
> generic formal parameters:
> type T_DEGRE_BASE is range <>;
> MAX: in T_DEGRE_BASE;
> 
> type definitions:
> subtype T_DEGRE is T_DEGRE_BASE range -MAX..MAX;
> type T_Vect_Coef is array (T_Degr
> type T_Polynome (Degre : T_Degre := 0) is
>      record
>          COEF : T_Vect_Coef (0..Degre) := (others => NULL_ELEMENT);
>      end record;e range <>) of ELEMENT;
> 
> And the actual generic parameters:
> package RAT is new P_RATIONNELS_G(T_ENTIER => INTEGER);
> package POLY is new P_POLY_V1_G(T_DEGRE_BASE => INTEGER,
>     ELEMENT => RAT.T_RATIONNEL, NULL_ELEMENT => RAT.NULLE, MAX => 10, PUT => RAT_IO.PUT);
> Lastly:
> subtype T_Entier_Pos is T_Entier range 1..T_Entier'Last;
> type T_Rationnel is record
>      Numerateur  : T_Entier  := 0;
>      Denominateur: T_Entier_Pos := 1;
> end record;

You have not provided enough information to determine what your problem really 
is. However, if you declare

Poly : T_Polynome (Degre => T_Degre'First);

then what are valid indices into Poly.Coef?

-- 
Jeff Carter
"Oh Lord, bless this thy hand grenade, that with it thou
mayst blow thine enemies to tiny bits, in thy mercy."
Monty Python and the Holy Grail
24

      reply	other threads:[~2018-01-04 16:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04 15:39 index range while type (seemingly defined) to always include this particular value Mehdi Saada
2018-01-04 16:19 ` Jeffrey R. Carter [this message]
replies disabled

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