From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generic warning
Date: Tue, 17 Jun 2008 21:04:38 +0200
Date: 2008-06-17T21:04:40+02:00 [thread overview]
Message-ID: <ttqeca6peob2.1jgze60x240ta.dlg@40tude.net> (raw)
In-Reply-To: g39028$2mk$1@registered.motzarella.org
On Tue, 17 Jun 2008 18:33:42 +0000, S�bastien Morand wrote:
>> Maybe it is just a compiler bug. But you should post a complete compilable
>> code.
No, it is not. The compiler is correct.
> Here is a complete code with the same warning:
>
> procedure Main is
>
> generic
> -- Element to be stored in the btree
> type Element (<>) is private;
> Order: Positive;
> package TestGen is
> type ElementPtr is access all Element;
> Buffer: array(1 .. Order*2) of ElementPtr;
> procedure Store(E: in Element; index: in Positive);
> end TestGen;
>
> package body TestGen is
> procedure Store(E: in Element; index: in Positive) is
> begin
> -- In my real procedure, index is calculated and there is some
> -- check. Index can't be > Order*2
> for i in Positive range Order+2 .. index-1 loop
The problem is here. You instantiate TestGen with Order = 1. So the upper
bound of Buffer is 2. Therefore the range is 1+2..Index, which should cause
Constraint_Error in Buffer(I).
Bravo GNAT! (Though the warning message could be better)
> Buffer(i) := new Element'(E);
> end loop;
> end Store;
> end TestGen;
> package IntTestGen is new TestGen(
> Element => Integer,
> Order => 1
> );
> use IntTestGen;
> begin
> Store(1, 4);
> end Main;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2008-06-17 19:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-17 16:44 Generic warning Sébastien Morand
2008-06-17 17:17 ` Dmitry A. Kazakov
2008-06-17 18:33 ` Sébastien Morand
2008-06-17 19:04 ` Dmitry A. Kazakov [this message]
2008-06-18 8:41 ` Sébastien Morand
2008-06-18 14:16 ` Brian Drummond
2008-06-18 14:32 ` Sébastien Morand
2008-06-18 14:39 ` Ed Falis
2008-06-18 14:42 ` Dmitry A. Kazakov
2008-06-18 15:10 ` Robert A Duff
2008-06-18 15:25 ` Dmitry A. Kazakov
2008-06-18 15:38 ` Ed Falis
2008-06-18 17:04 ` Dmitry A. Kazakov
2008-06-17 18:20 ` Jeffrey R. Carter
2008-06-18 8:55 ` Sébastien Morand
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox