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,ed6a891101ff4e06 X-Google-Attributes: gid103376,public From: Niklas Holsti Subject: Re: Freeing Pointers to classwide types Date: 1998/10/11 Message-ID: <362081E9.5CF38122@icon.fi>#1/1 X-Deja-AN: 399897881 Content-Transfer-Encoding: 7bit References: <1ftmFTC69GA.191@samson.airnet.net> <361E65A8.36082B5D@icon.fi> Content-Type: text/plain; charset=us-ascii Organization: Space Systems Finland Ltd Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-10-11T00:00:00+00:00 List-Id: Matthew Heaney wrote: > > Niklas Holsti writes: > > > Matthew Heaney wrote: > > [snip] > > > > > > type T_Access is access all T'Class; > > > for T_Access'Storage_Size use 0; [snip] > > In fact, the above code elicits the following message from GNAT: > > "Warning: implicit call of Initialize will raise Storage_Error." First, let me correct myself: GNAT actually warns that the implicit Initialize call will raise Program_Error, not Storage_Error. Moreover, this occurs with a rather old GNAT version (3.05); the version in WebAda does not emit this warning, so it was probably a fault in the old GNAT. Sorry for this confusion. > If you call new for an access type whose storage size is 0, then you'll > get Storage_Error. I don't think the LRM says precisely that. Storage_Error is raised if there is not enough storage, but defining Storage_Size as zero does not mean that the available storage is zero, since the compiler can make the storage pool larger than requested. Of course this may be an insignificant quibble, if all compilers actually provide exactly the requested size. On the other hand, it seems that GNAT (in WebAda) lets one specify a positive Storage_Size for an access type to a descendant of the type T, so it would seem possible for clients to use "new" for descendant types. Doesn't this break your approach? - Niklas