Hi,

On Mon, 18 Feb 2013, Jeffrey Walton wrote:

> On Mon, Feb 18, 2013 at 10:34 AM, Andrew Haley <a...@redhat.com> wrote:
> > On 02/18/2013 03:07 PM, Jeffrey Walton wrote:
> >> On Mon, Feb 18, 2013 at 9:43 AM, Jonathan Wakely <jwakely....@gmail.com> 
> >> wrote:
> >>> On 18 February 2013 13:28, Jeffrey Walton wrote:
> >
> >>>> 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.
> >> Its hypothetical, and could be a bit humorous. Why are developers
> >> writing programs that rely upon undocumented features?
> >
> > BSS being zero is certainly not an undocumented feature.
>
> C/C++ makes no assurances on the value of an unitialized variable, 
> members, etc.

Wrong.  It specifies that objects with static storage duration that 
aren't explicitely initialized are initialized with null pointers, or 
zeros depending on type.  6.7.8.10.

Hence if .bss is to be used to place such objects then the runtime system 
_must_ make sure that it's zero initialized.

IOW: it's only automatic and allocated variables that start with an 
indeterminate value when not initialized explicitely.  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.  And to initialize allocated variables 
with some bit pattern you can simply override malloc.  So, this option 
seems to search for a problem it's supposed to help with.


Ciao,
Michael.

Reply via email to