stdvector - Bounds checking of std::vector (and other containers) in clang? -


in clang, there way enable bounds checking [] access std::vectors , other stl containers, preferably when building in debug mode only?

i spent hours hunting down subtle bug turned out caused accessing past end of std::vector. doesn't need clever when detects error, trap in debugger can find out happened , fix in code.

is there way other "create own type inherits std::vector", i'd avoid?

(i'm using clang version 3.1 if makes difference.)

if you're using linux or os x should address sanitizer:

http://clang.llvm.org/docs/addresssanitizer.html

it introduces 2x slowdown, bunch of memory checking , may catch bug.

another amazing tool has saved me countless times valgrind. if can run valgrind catch ton of memory bugs , leaks.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -