Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #74388

Re: CAlive special use instance class, called an angel

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: CAlive special use instance class, called an angel
Date 2015-10-30 22:17 -0400
Organization A noiseless patient Spider
Message-ID <n1187t$9le$1@dont-email.me> (permalink)
References (3 earlier) <MPG.309ca0078690a92d5b@news.eternal-september.org> <77be262f-6ad6-4b73-bad7-e28d42fbc12a@googlegroups.com> <06012d90-75a1-49ae-80da-fb3959d5a842@googlegroups.com> <d9i7p4F2lrhU7@mid.individual.net> <878u6kdli5.fsf@bsb.me.uk>

Show all headers | View raw


On 10/30/2015 06:44 PM, Ben Bacarisse wrote:
> Ian Collins <ian-news@hotmail.com> writes:
> <snip>
>> Off topic I know, but it is the weekend...
>>
>> In C++ the destructor is called when the object goes out of scope,
> 
> That's not really true.  It's a common shorthand (I've probably said it
> myself) but it's wrong in two ways.  First objects don't have scope --
> only names have scope.  There are objects that come and go without
> names, and there are names with scope that don't name objects.  Second,
> a named object's destructor is called when control passes the end of the
> scope.  Names (of objects) go out of scope all the time without the
> destructor firing -- when a function is called, for example.
> 
> Even this is a bit of a simplification because of gotos and exceptions
> (in C++) but there's probably not much to gain by going further.
> 
> I am sure you know all this, and I am also sure that pointing it out
> will not really help, but "objects going out of scope" is, to me, like
> "I regularly go to the pub" and "there's a finite chance it will happen"
> -- something I find it almost impossible to avoid remarking on!

Implicit execution of an object's destructor is governed by 12.4p4, and
the word "scope" doesn't appear anywhere in that section. The idea that
it's the scope that matters comes from the fact that objects with
automatic storage duration have a lifetime that ends when the block
containing them exits, which is the same location where the scope of the
names of the objects ends (3.3.3p1). However, their lifetime can also
end when an exception is thrown.

For objects that don't have automatic storage duration, there's no
particular connection between the scope of the object's name and the
execution of of its destructor. Objects with static storage duration
have their destructors called at the end of the program. Objects with
thread storage duration have them called when the thread exits. The
destructors for temporary objects are called when their lifetime ends.
In fact, "lifetime ends" is an accurate description for all of those
categories.

Destructors of objects with dynamic storage duration never have their
destructors called implicitly. Objects created by the new operator have
the destructor called when the delete operator is used on them
(5.3.5p6).  If something meets the standard's requirements for an
allocator (17.6.3.5), then the destructor can also be invoked by calling
allocator.destroy(object) BEFORE calling allocator.deallocate(object).
For objects explicitly constructed in memory that is allocated using
calloc(), malloc(), realloc() or get_temporary_buffer(), destructors
have to be called equally explicitly.
-- 
James Kuyper

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 18:18 -0700
  Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 18:23 -0700
  Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-30 14:27 +1300
    Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 19:18 -0700
      Re: CAlive special use instance class, called an angel Philip Lantz <prl@canterey.us> - 2015-10-29 22:29 -0700
        Re: CAlive special use instance class, called an angel Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-29 22:53 -0700
          Re: CAlive special use instance class, called an angel gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-30 08:40 +0000
            Re: CAlive special use instance class, called an angel Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-30 01:49 -0700
              Re: CAlive special use instance class, called an angel Richard Heathfield <rjh@cpax.org.uk> - 2015-10-30 09:15 +0000
              Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 05:37 -0700
                Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 14:25 +0100
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 06:35 -0700
                Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 16:34 +0100
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 08:44 -0700
                Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 13:32 +0000
          Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 05:34 -0700
            Re: CAlive special use instance class, called an angel gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-30 13:13 +0000
              Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 06:25 -0700
            Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-31 11:03 +1300
              Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 15:17 -0700
                Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-31 16:55 +1300
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 21:13 -0700
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 21:36 -0700
                Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-31 17:44 +1300
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 21:53 -0700
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 21:57 -0700
                Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-31 22:16 +1300
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 09:50 -0700
                Re: CAlive special use instance class, called an angel Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-31 01:52 -0700
              Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 22:44 +0000
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 16:14 -0700
                Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-31 01:03 +0000
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 19:14 -0700
                Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-31 11:56 +0000
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 09:55 -0700
                Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-31 20:17 +0000
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 14:27 -0700
                Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-31 22:38 +0000
                Re: CAlive special use instance class, called an angel Richard Damon <Richard@Damon-Family.org> - 2015-10-31 10:44 -0400
                Re: CAlive special use instance class, called an angel Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-31 12:16 -0700
                Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-31 13:13 +1300
                Re: CAlive special use instance class, called an angel James Kuyper <jameskuyper@verizon.net> - 2015-10-30 22:17 -0400
                Re: CAlive special use instance class, called an angel James Kuyper <jameskuyper@verizon.net> - 2015-10-30 22:31 -0400
        Re: CAlive special use instance class, called an angel Philip Lantz <prl@canterey.us> - 2015-10-30 01:42 -0700
      Re: CAlive special use instance class, called an angel Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 09:38 +0000
        Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 04:35 -0700
          Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 14:10 +0100
            Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 06:21 -0700
              Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 16:43 +0100
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 08:55 -0700
                Re: CAlive special use instance class, called an angel Ian Collins <ian-news@hotmail.com> - 2015-10-31 11:09 +1300
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 15:19 -0700
                Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-11-01 00:47 +0100
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 17:24 -0700
                Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-11-01 23:39 +0100
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 16:50 -0800
                Re: CAlive special use instance class, called an angel Philip Lantz <prl@canterey.us> - 2015-11-01 23:22 -0800
                Re: CAlive special use instance class, called an angel Bartc <bc@freeuk.com> - 2015-11-02 13:54 +0000
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-02 06:23 -0800
                Re: CAlive special use instance class, called an angel supercat@casperkitty.com - 2015-11-01 18:46 -0800
            Re: CAlive special use instance class, called an angel Bartc <bc@freeuk.com> - 2015-10-30 13:55 +0000
  Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 10:16 +0100
    Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 05:39 -0700
      Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 14:38 +0100
        Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 06:59 -0700
          Re: CAlive special use instance class, called an angel Bartc <bc@freeuk.com> - 2015-10-30 14:41 +0000
            Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 08:31 -0700
            Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 08:38 -0700
            Re: CAlive special use instance class, called an angel asetofsymbols@gmail.com - 2015-10-30 08:39 -0700
              Re: CAlive special use instance class, called an angel supercat@casperkitty.com - 2015-10-30 15:20 -0700
          Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-10-30 16:48 +0100
            Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 09:07 -0700
              Re: CAlive special use instance class, called an angel David Brown <david.brown@hesbynett.no> - 2015-11-01 14:53 +0100
                Re: CAlive special use instance class, called an angel Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-01 06:12 -0800
                Re: CAlive special use instance class, called an angel Bartc <bc@freeuk.com> - 2015-11-02 14:16 +0000
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 06:25 -0800
                CLC as a dating site (Was: CAlive special use instance class, called an angel) gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-01 14:33 +0000
                Re: CLC as a dating site (Was: CAlive special use instance class, called an angel) "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 06:45 -0800
                Re: CAlive special use instance class, called an angel "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 07:53 -0800
                Using CLC for crowdsourcing (Was: CAlive special use instance class, called an angel) gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-01 15:56 +0000

csiph-web