comp.lang.ada
 help / color / mirror / Atom feed
From: Hyman Rosen <hyrosen@mail.com>
Subject: Re: Weird controlled behavior - Gnat 3.15p NT
Date: Thu, 11 Sep 2003 03:46:56 GMT
Date: 2003-09-11T03:46:56+00:00	[thread overview]
Message-ID: <QeS7b.13984$w41.275@nwrdny02.gnilink.net> (raw)
In-Reply-To: <592rlv0pak1cghri31iueh0mm144hv8kpm@4ax.com>

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).




  reply	other threads:[~2003-09-11  3:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-04 15:25 Weird controlled behavior - Gnat 3.15p NT Jano
2003-09-04 15:40 ` Martin Krischik
2003-09-04 18:06 ` Patrice Freydiere
2003-09-04 19:03   ` Jano
2003-09-04 20:57     ` Jano
2003-09-05  8:48     ` Preben Randhol
2003-09-05 13:48       ` Jano
2003-09-04 21:36 ` Robert I. Eachus
2003-09-05  4:04   ` Randy Brukardt
2003-09-05 13:48     ` Jano
2003-09-05 14:33       ` Dmitry A. Kazakov
2003-09-09  2:01   ` Hyman Rosen
2003-09-09  7:02     ` Jean-Pierre Rosen
2003-09-11  3:40       ` Hyman Rosen
2003-09-09  8:22     ` Dmitry A. Kazakov
2003-09-11  3:46       ` Hyman Rosen [this message]
2003-09-11  8:23         ` Dmitry A. Kazakov
2003-09-05  7:10 ` Jean-Pierre Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox