|
From: <fa...@ca...> - 2004-07-12 21:52:27
|
I'm running across a mismatched new/delete error in stable_sort() from
the STL. I'm using valgrind 2.1.1, gcc 3.4.1 on RHEL 3.0 (glibc 2.3.2).
Is this a known error in valgrind or the gnu STL, or (more likely) am I
doing something stupid?
Thanks for the great program!
- Matt
A simple test program:
#include <vector>
#include <algorithm>=20
#include <functional>
#include <iostream>
int main(int argc, char* argv[])=20
{
std::vector<int> data;
for (int i=3D0;i<100;i++) data.push_back(i%7);
stable_sort( data.begin(), data.end() );
std::cout << data[50] << std::endl;
}
Results in the error:
=3D=3D27651=3D=3D Mismatched free() / delete / delete []
=3D=3D27651=3D=3D at 0x3C01E87B: free (vg_replace_malloc.c:127)
=3D=3D27651=3D=3D by 0x3C0C78D0: operator delete(void*, std::nothrow_t
const&) (del_opnt.cc:39)
=3D=3D27651=3D=3D by 0x8049758: void std::return_temporary_buffer<int>(i=
nt*)
(memory:122)
=3D=3D27651=3D=3D by 0x80492E2:
std::_Temporary_buffer<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >, int>::~_Temporary_buffer()
(stl_tempbuf.h:129)
=3D=3D27651=3D=3D Address 0x3C2705A0 is 0 bytes inside a block of size 400=
alloc'd
=3D=3D27651=3D=3D at 0x3C01E5B6: operator new(unsigned, std::nothrow_t
const&) (vg_replace_malloc.c:110)
=3D=3D27651=3D=3D by 0x8049F37: std::pair<int*, int>
std::__get_temporary_buffer<int>(int, int*) (memory:81)
=3D=3D27651=3D=3D by 0x804972C: std::pair<int*, int>
std::get_temporary_buffer<int>(int) (memory:110)
=3D=3D27651=3D=3D by 0x804921B:
std::_Temporary_buffer<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >,
int>::_Temporary_buffer(__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >,
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >) (stl_tempbuf.h:153)
|