This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C/C++ Option to Initialize Variables?
On 18 February 2013 13:28, Jeffrey Walton wrote:
> The reason I went looking for the flag is someone asked about a crash
> on the OpenSSL mailing list. I knew it was due to an uninitialized
> field (but they did not realize the value was not initialized). I
> wanted to suggest a quick way to find what was not initialized.
Valgrind.
> How much code do you think would break because folks depend on getting
> a 0 due to good graces or side effects (for example, the memory
> manager returning a zeroized page)?
It should break no valid programs. The invalid programs that break
would benefit from an easily reproducable failure.
> What if the ".BSS" section was
> initialized to 0xFF rather than a page full of NULLs?
That could break millions of perfectly valid programs, for no obvious benefit.
> When building for tools such as Valgrind, don't specify the flag ;)
You don't build for valgrind, it runs normal, uninstrumented binaries.
That's one of its main advantages.