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,74b55538385b7366 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Which is right here - GNAT or OA ? Date: 1999/06/03 Message-ID: #1/1 X-Deja-AN: 485303629 References: <928083159.436.79@news.remarQ.com> NNTP-Posting-Date: Thu, 03 Jun 1999 09:03:28 PDT Newsgroups: comp.lang.ada Date: 1999-06-03T00:00:00+00:00 List-Id: "Vladimir Olensky" writes: > ---------------------------------- > -- Which is right here - GNAT or OA ? > --------------------------------- Both are, because the language doesn't specify what happens when you try to deallocate an object on the stack. Your code is erroneous. > I mentioned about my simple user GB examples few months ago in GB > thread but then I had no time to prepare them for open use. Then > there was nice article about smart pointers by Mathew Heaney > describing the same issue and I did not feel like adding anything else > to this subject. My philosophy is to declare the type in such a way so that the user has to use the type's allocator, and can't declare the object on the stack: type T (<>) is limited private; type T_Access is access all T; function New_T return T_Access; procedure Free (O : in out T_Access); procedure Op1 (O : access T); Using this technique, the problem you describe cannot happen.