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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b1a1ed8b075945 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn13feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Allocators and exceptions => Trying Again Reply-To: anon@anon.org (anon) References: <1189323618.588340.87180@o80g2000hse.googlegroups.com> <1189426567.755739.178270@r29g2000hsg.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Mon, 10 Sep 2007 22:10:29 GMT NNTP-Posting-Host: 12.65.114.132 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1189462229 12.65.114.132 (Mon, 10 Sep 2007 22:10:29 GMT) NNTP-Posting-Date: Mon, 10 Sep 2007 22:10:29 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:1871 Date: 2007-09-10T22:10:29+00:00 List-Id: The Constraint_Error will not alter the memory allocation. The only exception that effect memory allocation is the system generated Storage_Error. No other exception will alter memory. Which denotes a memory leak. Programmers can confuse the compiler that creates and allows memory leaked or unexplained deallocates. And its not the languages fault but the programmers. This might explain why it is not defined directly in the RM. The problem is that even though it is legal to have type T (Init : Integer) is record C : Positive := Positive (Init); end record; It does allows the concept of memory leaks to be introduce into a program. Some compile may use deallocation others may allow memory leaked, while other might do type checking first and generate the Constraint_Error before memory is allocate. If you used, instead: type T (Init : Positive ) is record C : Positive := Init ; end record ; then do the integer to positive conversion in the body like -- Note: Ptr := new T ( Positive ( -5 ) ); will generate a -- compiler warning, so C_Value : Constant Integer := -5 ; Ptr := new T ( Positive ( C_Value ) ) ; In this design the conversion of the Integer to Positive will generate the exception, before the system trys to allocate any memory. Which Guarantees, when the exception will happen and the programmer can predict how the system will react, else there is no Guarantee. For Memory Leaks: Read Chapter 21, of the "GNAT User Guide" it deals with memory leaks, with the use of debugging and "gnatmem". The example they use may not be like yours but in reading it you should be able to adapt the concept to your code. In <1189426567.755739.178270@r29g2000hsg.googlegroups.com>, Maciej Sobczak writes: >On 10 Wrz, 12:37, a...@anon.org (anon) wrote: > >> pragma Restrictions ( Immediate_Reclamation ) ; > >It does not apply to objects created by the allocator. > >It is useful only for those objects that are created implicitly, for >example return values of unconstrained types. > >My question still holds. And I'm still scared. > >-- >Maciej Sobczak >http://www.msobczak.com/ >