When executing the following snippet:
#include <list>
int main() { std::list<int> l; }
the function __common_pool_policy<__pool,true>::_S_get_pool() is called three
times! Yet the result of the call is discarded each time. As a matter of fact,
no memory has even been allocated by the program, so the pool is useless. These
three calls are due to the __mt_alloc class. Excerpt from ext/mt_alloc.h:655:
__mt_alloc() throw()
{ __policy_type::_S_get_pool(); }
__mt_alloc(const __mt_alloc&) throw()
{ __policy_type::_S_get_pool(); }
I didn't see anything in the online documentation ext/mt_allocator.html that
states that _S_get_pool must be called three times before _S_initialize_once can
even be called (this function is called by allocate). In fact, calling
_S_get_pool before the pool is initialized could be seen as a bug somehow.
Removing these useless __mt_alloc constructors would speed up both compile time
and execution time of programs using STL containers. The pool would then be
created by _S_initialize_once the first time allocate is called.
--
Summary: Class __mt_alloc overexerts __policy_type::_S_get_pool
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: guillaume dot melquiond at ens-lyon dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23956