On Mon, 18 Feb 2013, Michael Matz wrote: > Automatic variables, as they are on the stack, are unlikely to usually get > the value 0 out of pure luck, so an option to initialize them to 0xDEADBEAF > doesn't make much sense.
Hm, but the following comment from init-regs.c indicates that GCC will set some uninitialized vars to zero, except at -O0: /* Check all of the uses of pseudo variables. If any use that is MUST uninitialized, add a store of 0 immediately before it. For subregs, this makes combine happy. For full word regs, this makes other optimizations, like the register allocator and the reg-stack happy as well as papers over some problems on the arm and other processors where certain isa constraints cannot be handled by gcc. These are of the form where two operands to an insn my not be the same. The ra will only make them the same if they do not interfere, and this can only happen if one is not initialized. There is also the unfortunate consequence that this may mask some buggy programs where people forget to initialize stack variable. Any programmer with half a brain would look at the uninitialized variable warnings. */ However this seems to not touch variables with only may-uninitialized accesses. > And to initialize allocated variables with some bit pattern you can simply > override malloc. Or use MALLOC_PERTURB_ environment variable. -- Alexander