🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2590

Re: Global Init/Shutdown: A solution (hopefully)

#2590
From: Herb Sutter
Date: Wed, 15 Nov 1995 17:49
44 lines
2457 bytes
In article <9511141105.AA01230@lts.sel.alcatel.de>,
   James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:
>|> >Another interesting case:
>|> >
>|> >    A                   a1 ;
>|> >    A                   a2 ;
>|> >    A                   a3 ;
>|> >    //  ...
>|> >
>|> >The constructor of a2 throws an exception 

>|> Trying the above under BC++ 4.52, A::A() is called twice and then A::~A() 
>|> is called once, which is correct.
>
>The only compiler I have access to that supports exceptions is Sun CC
>4.0.1; this is the compiler I used for my initial tests.  I modified
>the test to call exit, instead of throwing an exception, and got the
>following results:
>
>					              ctors   dtors
>	Sun CC 4.0.1 (w/ exceptions)			2	3
>	Sun CC 2.1					2       0
>	Cfront 3.0.1 (direct port, not from Sun)	2	3
>	g++ 2.6.3					2	0
>	g++ 2.7.0					2	0

Hold on... you changed the question! :-)  If I modify my BC++ 4.52 program to 
call exit() (instead of throwing) in a2's ctor, I get the incorrect result of 
three A::~A() calls.  If I change it to call abort() in a2's ctor, I get zero 
A::~A()s.

Does the WP specify what/how dtors should be called in the case of an exit() 
or abort()?

Herb


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herb Sutter                 2228 Urwin, Ste 102         voice (416) 618-0184
Connected Object Solutions  Oakville ON Canada L6L 2T2    fax (905) 847-6019

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <48d93i$4ts@steel.interlog.com>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <199511110318.UAA24570@ncar.ucar.EDU> <4873sc$hum@gabi.gabi-soft.fr> <488tdp$1tu@steel.interlog.com> <9511141105.AA01230@lts.sel.alcatel.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: herbs@interlog.com (Herb Sutter)
Newsgroups: comp.std.c++
Subject: Re: Global Init/Shutdown: A solution (hopefully)
Date: 15 Nov 1995 17:49:24 GMT
Organization: Connected Object Solutions (div of Daystar Software Systems Design Inc.)
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <48d93i$4ts@steel.interlog.com>
References: <199511110318.UAA24570@ncar.ucar.EDU> <4873sc$hum@gabi.gabi-soft.fr> <488tdp$1tu@steel.interlog.com> <9511141105.AA01230@lts.sel.alcatel.de>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: herbs.interlog.com
X-Newsreader: News Xpress Version 1.0 Beta #4
Content-Length: 1450
X-Lines: 40
Originator: clamage@taumet