|
From: John R. <jr...@bi...> - 2015-04-08 06:09:46
|
> Hello, I was wondering if it is possible to partially mark > a memory location as undefined when running under valgrind. Quoting the documentation http://valgrind.org/info/tools.html : > Memcheck tracks addressability at the byte-level, and initialisation of values at the bit-level. As a result, it can detect the use of single uninitialised bits, and does not report spurious errors on bitfield operations Therefore: Run memcheck under a debugger, and watch while memcheck checks this program: ----- #include <stdlib.h> int *p; int main() { p = (int *)malloc(100); p[5] &= 0xec6da539; /* clear some bits, leave the rest uninit */ return p[0xff & p[5]]; /* indexing by uninit is an immediate error */ } ----- |