public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Static initialisation question...
@ 2001-04-24 10:52 Mike Harrold
  2001-04-24 15:15 ` Alexandre Oliva
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Harrold @ 2001-04-24 10:52 UTC (permalink / raw)
  To: gcc-help

Hi,

I know that there is no defined order of initialising static objects
when a program is run, so therefore it is inherently unsafe for one
static object to reference another.

My qeustion is if it is safe to assume that static member objects of
a base class are always initialised before statis member objects of
a derived class?

Thanks,

/Mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Static initialisation question...
  2001-04-24 10:52 Static initialisation question Mike Harrold
@ 2001-04-24 15:15 ` Alexandre Oliva
  2001-04-24 19:54   ` Mike Harrold
  0 siblings, 1 reply; 7+ messages in thread
From: Alexandre Oliva @ 2001-04-24 15:15 UTC (permalink / raw)
  To: Mike Harrold; +Cc: gcc-help

On Apr 24, 2001, Mike Harrold <mharrold@cas.org> wrote:

> My qeustion is if it is safe to assume that static member objects of
> a base class are always initialised before statis member objects of
> a derived class?

Is this a question about C++ the language (in which this is the wrong
forum) or about the g++ implementation on a certain platform (in which
case I don't know the answer anyway)?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Static initialisation question...
  2001-04-24 15:15 ` Alexandre Oliva
@ 2001-04-24 19:54   ` Mike Harrold
  2001-04-25  2:06     ` Ingo Krabbe
  2001-04-25 11:51     ` Alexandre Oliva
  0 siblings, 2 replies; 7+ messages in thread
From: Mike Harrold @ 2001-04-24 19:54 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Mike Harrold, gcc-help

> 
> On Apr 24, 2001, Mike Harrold <mharrold@cas.org> wrote:
> 
> > My qeustion is if it is safe to assume that static member objects of
> > a base class are always initialised before statis member objects of
> > a derived class?
> 
> Is this a question about C++ the language (in which this is the wrong
> forum) or about the g++ implementation on a certain platform (in which
> case I don't know the answer anyway)?

It's a question about the g++ implementation.

/Mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Static initialisation question...
  2001-04-24 19:54   ` Mike Harrold
@ 2001-04-25  2:06     ` Ingo Krabbe
  2001-04-25  5:51       ` Mike Harrold
  2001-04-25 11:51     ` Alexandre Oliva
  1 sibling, 1 reply; 7+ messages in thread
From: Ingo Krabbe @ 2001-04-25  2:06 UTC (permalink / raw)
  To: Mike Harrold; +Cc: gcc-help

> 
> It's a question about the g++ implementation.
> 
> /Mike
> 
I wouldn't try to use compiler implementation defined rules. G++ is a
developing project. Such rules can even change from one release to
another, and you would stress yourself if your program will do something
different in half a year, when you updated your distribution.

CU INGO

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Static initialisation question...
  2001-04-25  2:06     ` Ingo Krabbe
@ 2001-04-25  5:51       ` Mike Harrold
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Harrold @ 2001-04-25  5:51 UTC (permalink / raw)
  To: Ingo Krabbe; +Cc: gcc-help

> 
> > 
> > It's a question about the g++ implementation.
> > 
> > /Mike
> > 
> I wouldn't try to use compiler implementation defined rules. G++ is a
> developing project. Such rules can even change from one release to
> another, and you would stress yourself if your program will do something
> different in half a year, when you updated your distribution.

Regardless, I'd still like an answer to the question. The way I see it
(and I don't know if the C++ standard covers this in any way) it would
seem that static objects of a base class must be initialised first as
it just makes common sense. From my own experiments, this appears to be
the case with g++ (although maybe I just got lucky :) ). What I am
interested in is if there is any design scheme for g++ which dictates
that this is either done, not done, or is totally random.

Regards,

/Mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Static initialisation question...
  2001-04-24 19:54   ` Mike Harrold
  2001-04-25  2:06     ` Ingo Krabbe
@ 2001-04-25 11:51     ` Alexandre Oliva
  2001-04-25 11:55       ` Mike Harrold
  1 sibling, 1 reply; 7+ messages in thread
From: Alexandre Oliva @ 2001-04-25 11:51 UTC (permalink / raw)
  To: Mike Harrold; +Cc: gcc-help

On Apr 24, 2001, Mike Harrold <mharrold@cas.org> wrote:

>> 
>> On Apr 24, 2001, Mike Harrold <mharrold@cas.org> wrote:
>> 
>> > My qeustion is if it is safe to assume that static member objects of
>> > a base class are always initialised before statis member objects of
>> > a derived class?
>> 
>> Is this a question about C++ the language (in which this is the wrong
>> forum) or about the g++ implementation on a certain platform (in which
>> case I don't know the answer anyway)?

> It's a question about the g++ implementation.

Still, you failed to mention which platform your question applies to.
The answer may well change from platform to platform, since it's quite
dependent on properties of the run-time loader.  Even more so if you
thrown shared libraries and dlopened modules into the picture.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Static initialisation question...
  2001-04-25 11:51     ` Alexandre Oliva
@ 2001-04-25 11:55       ` Mike Harrold
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Harrold @ 2001-04-25 11:55 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Mike Harrold, gcc-help

> 
> On Apr 24, 2001, Mike Harrold <mharrold@cas.org> wrote:
> 
> >> 
> >> On Apr 24, 2001, Mike Harrold <mharrold@cas.org> wrote:
> >> 
> >> > My qeustion is if it is safe to assume that static member objects of
> >> > a base class are always initialised before statis member objects of
> >> > a derived class?
> >> 
> >> Is this a question about C++ the language (in which this is the wrong
> >> forum) or about the g++ implementation on a certain platform (in which
> >> case I don't know the answer anyway)?
> 
> > It's a question about the g++ implementation.
> 
> Still, you failed to mention which platform your question applies to.
> The answer may well change from platform to platform, since it's quite
> dependent on properties of the run-time loader.  Even more so if you
> thrown shared libraries and dlopened modules into the picture.

I'm on Linux, but the more I think about it, the more I realise that
because of the dlopen() conundrum, you can't guarantee anything, right?

/Mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-04-25 11:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-24 10:52 Static initialisation question Mike Harrold
2001-04-24 15:15 ` Alexandre Oliva
2001-04-24 19:54   ` Mike Harrold
2001-04-25  2:06     ` Ingo Krabbe
2001-04-25  5:51       ` Mike Harrold
2001-04-25 11:51     ` Alexandre Oliva
2001-04-25 11:55       ` Mike Harrold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).