This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ordering of constructors


On Fri, Apr 09, 2004 at 03:33:20PM +0200, Gabriel Dos Reis wrote:
> 3.6.2/3
> 
>   It is implementation-defined whether or not the dynamic
>   initialization (8.5, 9.4, 12.1, 12.6.1) of an object of namespace
>   scope is done before the first statement of main. If the
>   initialization is deferred to some point in time after the first
>   statement of main, *it shall occur before the first use of any
>   function or object defined in the same translation unit as the
>   object to be initialized*. 

Unfortunately, in many cases this guarantee doesn't help matters, as
crashes due to contructor order problems can occur before main is called,
and before main there are no ordering guarantees.  So your
make_sure_a_is_initialized trick offers no such guarantee if main has
not yet been called.
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]