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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,19bd7ab0daefd69b X-Google-Attributes: gid103376,public From: smize@news.imagin.net (Samuel Mize) Subject: Re: Storage_Error with parameterized records Date: 1998/07/10 Message-ID: <6o5b7r$36aq$1@prime.imagin.net>#1/1 X-Deja-AN: 370222679 References: <359D3A0C.13AF4C53@cl.cam.ac.uk> Organization: ImagiNet Communications Ltd, Arlington, Texas Reply-To: smize@imagin.net (Samuel Mize) Newsgroups: comp.lang.ada Date: 1998-07-10T00:00:00+00:00 List-Id: If you create an unconstrained instance of this type, your compiler allocates enough space to hold the largest example: an array of Natural*Natural elements. This is large. If you only create constrained instances, you should be OK. If you need to be able to change the constraint, you need to determine the largest constraint you may need, and use a subtype constrained by that maximum value (instead of Natural) for the constraint. Depending on how smart the compiler is, you may need to use that subtype for the indices of CMatrix too. Best, Sam Mize In article <359D3A0C.13AF4C53@cl.cam.ac.uk>, Markus Kuhn wrote: >May be I have something severely missunderstood, but I have no idea, >why the declaration > > subtype Correlation_Coefficient is Float; > > type CMatrix is > array (Natural range <>, Natural range <>) of > Correlation_Coefficient; > > type Correlation_Matrix(Last_Line : Natural := 0) is > record > Mat : CMatrix(0 .. Last_Line, 0 .. Last_Line); > end record; > >causes the following warnings (and at runtime the promised >Storage_Error): > > warning: Storage_Error will be raised at run-time > warning: creation of object of this type may raise Storage_Error -- Samuel Mize -- smize@imagin.net (home email) -- Team Ada Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam