🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #121

Re: object create order

#121
From: Sten Larsson
Date: Thu, 11 Nov 2004 08:22
25 lines
2140 bytes
Chris Uzdavinis (TeamB) wrote:
>Yes.  Static local variables of functions are not protected, and are
>constructed the first invocation.  If two threads both call the same
>function at the same time, then the single static member could be
>constructed multiple times.  If that's not bad enough, at program
>shutdown, it could get multiply destroyed, depending on how that gets
>setup, which may (should) crash your program.

Yes - I know... I just want to use some trick to guarantee that
objects exist when I need them too. As far as I remember, with these
global objects:

string a;
string b;

There is really no way of knowing if a or b is created first (by
reading the C++ standard), and this pretty much happens before the
main thread kicks in (well, at least before main() is called.

Creating the objec using "new" instead of a local static wouldn't
really improve things... right? I'm sure it would be a different error
behaviour instead.

Thanks!.
-sten
Technical Details
Message-ID: <r086p0l46hi788h2208h1hf0egp14p9hvp@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!news-FFM2.ecrc.net!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <kcdqo0t2f0vkit49u0l9goji42stukiq17@4ax.com> <418ed304$1@newsgroups.borland.com> <g2uto0p62cvgkccrnnd13dke6vf19d9m94@4ax.com> <adu3p0ha0a5ur21ssd817c6ugqegigee72@4ax.com> <cgs4p0pdn91rqd3f9gq16po2481g2dqm86@4ax.com> <r6t4p09hq6msmtm862t76ohmk6et7fg6di@4ax.com> <j5zn1pqq9i.fsf@explicit.atdesk.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,7fd39362bd6d0fe2
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Sten Larsson <stenX@Xstenl.com>
Newsgroups: borland.public.cppbuilder.oodesign
Subject: Re: object create order
Date: Thu, 11 Nov 2004 00:22:03 -0800
Message-ID: <r086p0l46hi788h2208h1hf0egp14p9hvp@4ax.com>
References: <kcdqo0t2f0vkit49u0l9goji42stukiq17@4ax.com> <418ed304$1@newsgroups.borland.com> <g2uto0p62cvgkccrnnd13dke6vf19d9m94@4ax.com> <adu3p0ha0a5ur21ssd817c6ugqegigee72@4ax.com> <cgs4p0pdn91rqd3f9gq16po2481g2dqm86@4ax.com> <r6t4p09hq6msmtm862t76ohmk6et7fg6di@4ax.com> <j5zn1pqq9i.fsf@explicit.atdesk.com>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.110.17.203
X-Trace: newsgroups.borland.com 1100161285 69.110.17.203 (11 Nov 2004 00:21:25 -0700)
Lines: 25
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!news-FFM2.ecrc.net!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail