🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2546
From: Herb Sutter
Date: Tue, 14 Nov 1995 02:17
38 lines
2494 bytes
In article <4873sc$hum@gabi.gabi-soft.fr>,
   kanze@gabi-soft.fr (J. Kanze) wrote:
>Another interesting case:
>
>    A                   a1 ;
>    A                   a2 ;
>    A                   a3 ;
>    //  ...
>
>The constructor of a2 throws an exception (not caught, of course).  In
>no case can the compiler be allowed to call the destructor to a3.  All

Or a2 for that matter, at least not according to C++PL2 sec 9.4.1 par 2.

>of the compilers I've tested do.  Which in practice means that you
>cannot safely let an exception escape from a constructor unless you can
>guarantee that the type can never be used as a static variable with file
>scope.  (Gee, and I always thought that one of the main reasons for
>using exceptions was error reporting from constructors.)

Trying the above under BC++ 4.52, A::A() is called twice and then A::~A() is 
called once, which is correct.  Just out of curiosity, what compilers acted 
improperly?  Pls. email the answer if this is drifting off-topic for c.s.c++. 
 Thanks.

	[Moderator's note: personally I'd be inclined to say that discussion
	of which compilers are standard-conforming in some particular respect
	is appropriate for comp.std.c++.  If anyone has any comments or
	suggestions about the moderation policy, please send them to
	std-c++-request@ncar.ucar.edu.  -fjh.]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: <488tdp$1tu@steel.interlog.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <199511110318.UAA24570@ncar.ucar.EDU> <4873sc$hum@gabi.gabi-soft.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 14 Nov 95 02:17:26 GMT
Approved: fjh@cs.mu.oz.au
From: herbs@interlog.com (Herb Sutter)
Newsgroups: comp.std.c++
Subject: Re: Global Init/Shutdown: A solution (hopefully)
X-Original-Date: Tue, 14 Nov 95 02:05:23 GMT
Organization: Connected Object Solutions (div of Daystar Software Systems Design Inc.)
Message-ID: <488tdp$1tu@steel.interlog.com>
References: <199511110318.UAA24570@ncar.ucar.EDU> <4873sc$hum@gabi.gabi-soft.fr>
X-Newsreader: News Xpress Version 1.0 Beta #4
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMKf+RuEDnX0m9pzZAQHNywF/SrmuojANK205s5Qg1bXX+wryzzIxhkBe
 CN0N7m7x1+kfJx3zmWidAXRiZsQdcLSH
 =NaHc