How to debug C++ memory errors?
Does valgrind work with STL allocator? I am using STL vector with plain C library in the follwing fashion:
double some_C_functions(int, double*);
std::vector<double> v;
.....
double result = some_C_functions(v.size(), &v[0]);
开发者_运维知识库
What if the C functions tries to overshoot the pointer? Can valgrind detect the error?
Valgrind should still be able to detect that since it's hooking into the memory management which still goes to the same heap for C or C++. Obviously it's hard(er) to detect errant reads though.
精彩评论