This is the mail archive of the
mailing list for the GCC project.
Re: Forced initializing scalars
- From: Chris Lattner <sabre at nondot dot org>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: Joe Buck <jbuck at synopsys dot com>, <gcc at gcc dot gnu dot org>,<gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Feb 2003 12:37:25 -0600 (CST)
- Subject: Re: Forced initializing scalars
>> For floating point, a signaling NaN can be used. For integers,
>> 0xdeadbeef or some such.
>> [ cases where gcc can't figure out that a variable is uninitialized ]
>>>> Despite the small cost, this could be a real help to some people...
>> It should be possible to turn the feature off.
>turned on at -O0, off at other levels?
That would make sense to me. Actually, it seems like two different
flavors of this option could be useful:
* At -O0, initialize stuff to SNaNs, deadbeef, or any other value that
is likely to trip people up. Arrays are probably best left
uninitialized. We could even go so far as to transform a call to malloc
into a call to malloc and memset of some non-zero value... there are a
lot of permutations to this which could be useful...
* When optimizing, have a (defaulting to off) -fzero-initialize-scalars
option, which could be used for people whose code stops working the same
when optimization is turned on.
The former would be great for people developing with GCC, the later would
be useful for people who (for some reason) don't want to debug their code,
and it breaks under optimization.