summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-01 02:21:51 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-01 02:21:51 +0000
commit494b35aa36b3d4693d7f8d9ca3456feaec657fcd (patch)
tree991cf077a1b58dd4459724aade2ab988d4f9d694 /libstdc++-v3
parenta4082e297a1bf0a99f718b855f34a7ee140e40cb (diff)
downloadgcc-494b35aa36b3d4693d7f8d9ca3456feaec657fcd.tar.gz
2004-06-30 Brad Spencer <spencer@infointeractive.com>
* include/ext/mt_allocator.h: Handle allocations at static initialization that happen before _S_options is (automatically) constructed; set _S_init even if _M_force_new is true. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83949 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/ext/mt_allocator.h21
2 files changed, 25 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2b2e0fa1033..4f19d105255 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-30 Brad Spencer <spencer@infointeractive.com>
+
+ * include/ext/mt_allocator.h: Handle allocations at static
+ initialization that happen before _S_options is (automatically)
+ constructed; set _S_init even if _M_force_new is true.
+
2004-06-30 Benjamin Kosnik <bkoz@redhat.com>
* config/linker-map.gnu: Revert new exports.
diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
index 8812c2df44b..f0ee2ebd26d 100644
--- a/libstdc++-v3/include/ext/mt_allocator.h
+++ b/libstdc++-v3/include/ext/mt_allocator.h
@@ -488,8 +488,25 @@ namespace __gnu_cxx
__mt_alloc<_Tp>::
_S_initialize()
{
- if (_S_options._M_force_new)
- return;
+ // This method is called on the first allocation (when _S_init is still
+ // false) to create the bins.
+
+ // Ensure that the static initialization of _S_options has
+ // happened. This depends on (a) _M_align == 0 being an invalid
+ // value that is only present at startup, and (b) the real
+ // static initialization that happens later not actually
+ // changing anything.
+ if (_S_options._M_align == 0)
+ new (&_S_options) _Tune;
+
+ // _M_force_new must not change after the first allocate(),
+ // which in turn calls this method, so if it's false, it's false
+ // forever and we don't need to return here ever again.
+ if (_S_options._M_force_new)
+ {
+ _S_init = true;
+ return;
+ }
// Calculate the number of bins required based on _M_max_bytes.
// _S_bin_size is statically-initialized to one.