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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: david.c.hoos.sr@ada95.com Subject: Re: Storage_Error with parameterized records Date: 1998/07/05 Message-ID: <6nntf2$u2m$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 368684454 References: <359D3A0C.13AF4C53@cl.cam.ac.uk> X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sun Jul 05 13:01:22 1998 GMT Newsgroups: comp.lang.ada Date: 1998-07-05T00:00:00+00:00 List-Id: 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 > > I had hoped this code was sufficiently close to John Barnes > Square example in chapter 16 of Programming in Ada 95 and I also > didn't find a restriction in the RM that explained this warning. > > And idea? > > Markus > > -- > Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK > email: mkuhn at acm.org, home page: > You didn't supply sufficient information to give a definitive answer. E.g., you did not supply: 1. The compiler and platform you are using 2. The value of the discriminant with which the record object was declared. If you consider that the range of type Natural on a 32-bit platform, and a 32- bit size for type Float could call for just under 2 ** 63 bytes of memory for an object of type Correlation_Matrix, then the reason for the warning "creation of object of this type may raise Storage_Error" should be obvious. The warning "Storage_Error will be raised at run-time" comes as a consequence of declaring an object which is too large for the implementation. E.g., with gnat-3.10p1 on Windows NT 4.0 (SP 3), an object of type Correlation_Matrix declared with a discriminant of 8190 does not raise Storage_Error at run time. (The actual limit on the discriminant may depend on how much other code there is in your program). This size object represents just under 256 Mb. of memory. Depending on the implementation, the limits may be more severe. E.g., depending on whether the object was declared statically (e.g., in a package body), on the stack, or using dynamic memory, the maximum size of an object may differ. Finally, even though you may restrict the declarations such that the compile- time warnings are eliminated, bear in mind that there may be run-time Storage_Errors, if too many instances of legal-sized objects are created. Hope this helps. David C. Hoos, Sr. -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum