comp.lang.ada
 help / color / mirror / Atom feed
* index range while type (seemingly defined) to always include this particular value
@ 2018-01-04 15:39 Mehdi Saada
  2018-01-04 16:19 ` Jeffrey R. Carter
  0 siblings, 1 reply; 2+ messages in thread
From: Mehdi Saada @ 2018-01-04 15:39 UTC (permalink / raw)


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;





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: index range while type (seemingly defined) to always include this particular value
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey R. Carter @ 2018-01-04 16:19 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-04 16:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox