On Thu, 2016-11-03 at 15:36 -0700, Patrick J. LoPresti wrote: > Right now, if I have code like this: > int a; /* invalid value */ > int b = a + 1; /* operation on invalid value */ > ...memcheck does not produce a warning for the addition. It just > taints b as invalid and only generates a warning if I try to use b in > a behavior-changing way. This is good, and it is exactly what I want. > > > However, if instead I have this code: > int a; /* invalid value */ > int b; > if (a > 0) /* conditional on invalid value */ > b = a; > else > b = 0; > ...memcheck produces a warning on the conditional branch. But if you > look at what this code actually computes, it is just "b = max(a,0)", > which is not so different from "b = a + 1". (That is, b is just some > simple function of a.) I want to teach memcheck to treat this second > example like the first; that is, just taint b as invalid if a is > invalid. I am not sure to understand how you will differentiate the above if (a > 0) b = a; else b = 0;
from if (a > 0) { b = a; launch_all_missiles(); } else b = 0; What we want is an error when the 'outside visible behaviour' of the program depends on uninit values. When a jump is processed, how do we know that the jump is jumping to a location that will have no outside visible effect ? For sure, we need/must have a valgrind error for the above case, otherwise we risk a nuclear 3rd world war :). Or maybe the idea is to do that only for very specific way to compile if (a > 0) when the then/else branches are only assignment to b ? This case seems very specialised to me, probably depending a lot from the compiler and compiler optimisation options. Is such code creating many false positive ? Philippe ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users