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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,edd7ea1b2d7e9a18 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-13 09:48:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Pitfall: freeing access discriminants Date: 13 Feb 2003 12:40:36 -0500 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1045158819 14345 128.183.235.92 (13 Feb 2003 17:53:39 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 13 Feb 2003 17:53:39 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:34063 Date: 2003-02-13T17:53:39+00:00 List-Id: porton@ex-code.com (Victor Porton) writes: > type Integer_Access is access Integer; > > type T(D: access Integer) is Ada.Limited_Controlled with null record; > > procedure Finalize(Object: in out T) is > -- Error: cannot convert access discriminant to non-local access type > D: Integer_Access := Integer_Access(Object.D); > begin > Free(D); > end; > > What to do? It seems being a serious deficiency in Ada or there are a > workaround? Why would you ever want to free an access discriminant? I usually use them to point to a constant object. One good rule for dynamic memory allocation; never free something you did not allocate. -- -- Stephe