This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C/C++ Option to Initialize Variables?


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.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]