Joshua Hale wrote:
Any suggestions for a debugging tool to help find out of bounds
writes/reads to arrays in a C++ program on a Linux platform? I tried
valgrind, and it found some accesses of uninitialized values, but can't
pick out out-of-bounds writes to stack arrays...
Thanks,
Josh.
Hmmm, difficult:
void my_function(char * pointer)
{
for (unsigned int i = 0; i < 100; ++i)
{
pointer[i] = 'b';
}
return;
}
int main(void)
{
char small_array[6];
char large_array[512];
my_function(large_array);
my_function(small_array);
return 0;
}
In the function my_function above, how is the tool
to know when the array has gone past its bounds?
The function has no clue as to the length of the
memory region passed to it.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library