This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

valgrind confused by std::allocator calls to operator new(0)





On gcc-3.4.3 and 4.0 new_allocator<T>::allocate(0) will call
operator new(0). Additionally, in gcc-3.4.3 std::allocator is an alias
to new_allocator. As a result, operator new(0) will be called simply
by using std::vector in gcc-3.4.3.

There are 2 issues with this:
1. Potential efficiency problem.
2. It confuses valgrind (I have created 99923 KDE PR.).

Consider something like:
  static vector<int> empty;
  static vector<int> *p= new vector<int>(empty); //calls operator new(0);

Valgrind erroneously reports p->_M_impl->_M_start as lost.
It should have reported it as "still reachable".

It may be viewed as a low priority regression. In gcc-3.2 std::allocator
does not behave this way.

Is it possible/reasonable to change new_allocator::allocate such that
it returns NULL when __n ==0 ? Should I open a PR against libstdc++?



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