Article View: comp.std.c++
Article #2518Re: Global Init/Shutdown: A solution (hopefully)
From: Robert Coie
Date: Fri, 10 Nov 1995 01:15
Date: Fri, 10 Nov 1995 01:15
33 lines
1912 bytes
1912 bytes
In article <AI-HDemqX1@qsar.chem.msu.su>, "Eugene Radchenko"
<eugene@qsar.chem.msu.su> wrote:
: Hi people!
: I have got a few ideas concerning the static init/shutdown problem which I
: would like to see discussed and criticized here.
:
: The major problem is to ensure the right order of initialization (and
: the inverse right order of destruction ;) between the translation units.
: I think it can be solved by requiring that this initialization
: really happens 'just' before the objects/functions in it are first accessed
: - which may even happen before main() - when exactly is unimportant.
[snip]
I don't see how this can be guaranteed. The simplest pathological case I
can think of (although trivial) is:
struct A { A(); };
A stA;
A::A() {}
I can't see how you can guarantee that the initialization of stA occurs
before the call to the constructor used to initialize it. The burden on
insuring that static objects are properly constructed before they are
referenced must fall, in the end, on the programmer, as far as I can see.
Robert Coie
Implementor, Intrigue Corporation
rac@intrigue.com
---
[ 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:
<rac-0911951237030001@intrigue.intrigue.com>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<AI-HDemqX1@qsar.chem.msu.su>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 10 Nov 95 01:15:20 GMT Approved: fjh@cs.mu.oz.au From: rac@intrigue.com (Robert Coie) Newsgroups: comp.std.c++ Subject: Re: Global Init/Shutdown: A solution (hopefully) X-Original-Date: Thu, 09 Nov 1995 12:37:03 -0800 Organization: Intrigue Corporation Message-ID: <rac-0911951237030001@intrigue.intrigue.com> References: <AI-HDemqX1@qsar.chem.msu.su> X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMKKnweEDnX0m9pzZAQEjpQGAhq5hC0jQD5FGU4wg8ueFTQF1blFGEcJj LVUQnk+BXxmP5erDwwjDttbo/ZMnDeF8 =yWgG