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:06:58
#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):
Ah! This is just the sort of explanation I was looking for, but could not
find--I guess my copy of the C++ standard has gone stale.
Based on this, it certainly would appear that GCC's behavior is conformant
and that the combination of fast_pool_allocator and singleton_default
presumes behavior which is unspecified.
My only concern is whether referencing singleton_default from the
constructor for fast_pool_singleton will guarantee proper initialization
ordering.
3.6.2 doesn't really shed any light on how ordered and unordered
initialization may be coupled. There isn't, for example, any expressed
guarantee that non-locals will be initialized prior to first reference.
== More from JoaquÃn: ==
There is no such guarantee indeed, but the fix does NOT rely on
initialization rules for non-local objects, but on the initialization
rules for *local* objects with static storage duration (6.7/4): the
singleton is a local static object inside the function
singleton_default<T>::instance(), which is explicitly invoked inside
fast_pool_allocator ctors via singleton_pool<...>is_from() (if you apply
the fix, that is).
The non-local object involved in singleton_default<T>, namely
singleton_default<T>::create_object is there to guarantee that
singleton_default<T>::instance() is invoked, and thus the singleton
created in dynamic initialization time *if no one has done it before*.
-- Ticket URL: <http://svn.boost.org/trac/boost/ticket/2359#comment:2> 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