Re: [Boost-bugs] [Boost C++ Libraries] #2359: Static initialization problems with fast_pool_allocator

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2359: Static initialization problems with fast_pool_allocator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-09-22 21:02:18


#2359: Static initialization problems with fast_pool_allocator
---------------------------+------------------------------------------------
  Reporter: cnewbold | Owner: cnewbold
      Type: Bugs | Status: new
 Milestone: Boost 1.37.0 | Component: pool
   Version: Boost 1.36.0 | Severity: Problem
Resolution: | Keywords:
---------------------------+------------------------------------------------

Comment(by cnewbold):

 I'm not sure I buy this explanation entirely.

 owned_base::pool_ is a global object. As described above, so is
 object_creator.

 The test case consists of a single translation unit, and inside that
 translation unit, the declaration of object_creator precedes that of
 owned_base::pool_ (because object_creator is declared by a Boost.Pool
 header which is included before the application-level code which declares
 owned_base).

 Following the fairly clear rules about initialization order for namespace-
 scoped global objects, I would have expected the compiler to construct
 object_creator first (and therefore the pool) before constructing
 owned_base::pool_.

 I'm not at all convinced that singleton_default or fast_pool_allocator is
 actually correct, but I do think this situation is a bit more complex...

 == More from Joaquín ==

 These precedence rules do not apply to class template static data: quoting
 the standard (latest draft at [http://www.open-
 std.org/jtc1/sc22/wg21/docs/papers/2008/n2691.pdf]),
 section 3.6.2:


   "Dynamic initialization of a non-local object with static storage
   duration is either ordered or unordered. Definitions of explicitly
   specialized class template static data members have ordered
   initialization. Other class template static data members (i.e.,
   implicitly or explicitly instantiated specializations) have unordered
   initialization. Other objects defined in namespace scope have ordered
   initialization. Objects with ordered initialization defined within a
   single translation unit shall be initialized in theorder of their
   definitions in the translation unit."

 That is, only *ordered* file-scope objects are subject to the precedence
 rule you're referring to. Class template static data are not ordered by
 definition (except if belonging to a full specialization). So, the
 sequence I proposed above is consistent AFAICS.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2359#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC