tags:

views:

305

answers:

1

Is there any way to do array bounds checking with g++? Valgrind can't detect overflows on arrays allocated on the stack. Additionally, the argument -fbounds-checking is only implemented for gcc (according to http://www.lrde.epita.fr/~akim/ccmp/doc/bounds-checking.html). Ideally, the source code shouldn't be modified in any way.

+1  A: 

There is a tool - experimental - called Ptrcheck that does check stack array bound overrun. Run Valgrind with the following option:

--tool=exp-ptrcheck

Here is some information on Ptrcheck: http://valgrind.org/docs/manual/pc-manual.html

Demi