C/C++ Option to Initialize Variables?
Michael Matz
matz@suse.de
Tue Feb 19 12:33:00 GMT 2013
Hi,
On Mon, 18 Feb 2013, Alexander Monakov wrote:
> 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:
Yes, that's for pseudos, i.e. scalar automatic variables, doesn't work for
may-uninitialized or aggregates and would be unnecessary with -Werror, as
must-uninitialized can be and are detected without false positives. The
value could be made configurable but I wouldn't see the point.
Ciao,
Michael.
More information about the Gcc
mailing list