C/C++ Option to Initialize Variables?

Uday Khedker uday@cse.iitb.ac.in
Mon Feb 18 16:39:00 GMT 2013



On Monday 18 February 2013 09:44 PM, Jeffrey Walton wrote:
> On Mon, Feb 18, 2013 at 10:34 AM, Andrew Haley <aph@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.gcc@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.
>
> DATA section is initialized data. BSS section is unitialized data.
>
> For statically allocated unitintialized object, it will go in BSS
> section. For uninitialized stack variable, it will go on the stack.
>
> Forgive me, but I don't see where anything is guaranteed to be zero'd
> before use. I'm likely wrong somewhere since you disagree.

http://en.wikipedia.org/wiki/.bss

Uday.



More information about the Gcc mailing list