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
Post a Comment