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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: index range while type (seemingly defined) to always include this particular value Date: Thu, 4 Jan 2018 17:19:27 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 4 Jan 2018 16:19:28 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="6c30139cc041ce9575bdf8483adc7ead"; logging-data="6017"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fP3MyeihXb7QXzLqKAfP/ke2DRriCrhw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:2j9qDzG1rMc3dZqantTkzVWx8C0= Xref: reader02.eternal-september.org comp.lang.ada:49752 Date: 2018-01-04T17:19:27+01:00 List-Id: 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