Forced initializing scalars

Chris Lattner sabre@nondot.org
Fri Feb 14 18:34:00 GMT 2003


>> 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?
>nathan

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.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/



More information about the Gcc-patches mailing list