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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,80e74153f40106ab X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-10 20:46:57 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!cycny01.gnilink.net!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!53ab2750!not-for-mail From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030901 Thunderbird/0.2 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Weird controlled behavior - Gnat 3.15p NT References: <5d6fdb61.0309040725.3403aa29@posting.google.com> <3F57B071.5030206@attbi.com> <592rlv0pak1cghri31iueh0mm144hv8kpm@4ax.com> In-Reply-To: <592rlv0pak1cghri31iueh0mm144hv8kpm@4ax.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 11 Sep 2003 03:46:56 GMT NNTP-Posting-Host: 162.84.176.54 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1063252016 162.84.176.54 (Wed, 10 Sep 2003 23:46:56 EDT) NNTP-Posting-Date: Wed, 10 Sep 2003 23:46:56 EDT Xref: archiver1.google.com comp.lang.ada:42370 Date: 2003-09-11T03:46:56+00:00 List-Id: Dmitry A. Kazakov wrote: > You might say that the above is rubbish. Not at all. It is a design > pattern for self-destructing objects. Not at all. It's a well-known and good pattern, as you say. > Now imagine what should happen if somebody would allocate > Foo on the stack? Undefined behavior. You are not allowed to do that, and if you do, the behavior of the program is unspecifed by the language. (The workaround is to make the destructor protected, by the way. Then the compiler will prevent such objects from being allocated on the stack, because the destructor will be inaccessible.) If you call a destructor yourself, you must make sure that the compiler will not call the destructor again on that object (which in fact no longer exists, except as a region of storage with undefined contents).