开发者

C++ - detect out-of-range access

I would like to analyse my C++ code to find bad access in vectors and arrays (out of range access), is there 开发者_开发问答a tool for that ?

thanks in advance


You can compile with _GLIBCXX_DEBUG and _GLIBXX_DEBUG_PEDANTIC defined if your are using gcc. This will enable glibc assertions to be raised if out of bounds access is requested.

Testing with valgrind::memcheck will also reveal bad memory reads


Yes: Valgrind.

And many others: http://en.wikipedia.org/wiki/Memory_debugger.

Note also that most implementations of e.g. std::vector have a debug mode where they will do run-time bounds checking.


There are some paid tools, which does static analysis:

klockwork

coverity

IBM Rational Purify does dynamic analysis.


create a class on you arrays and create some controlling functions in that class with operators and .... then use this class .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜