Graham Percival <gra...@percival-music.ca> writes:

> On Wed, Aug 17, 2011 at 05:53:40AM -0600, Carl Sorensen wrote:
>> \On 8/16/11 10:25 PM, "Dan Eble" <d...@faithful.be> wrote:
>> 
>> > Is there a reason that these variables in lily/profile.cc don't need to be
>> > initialized?  I don't have experience with guile, but it looks dangerous.
>> 
>> I guess the code in this section relies on the fact that the compiler will
>> initialize the unitialized value to zero.   Do you believe that is a
>> problem?
>
> Is there a special rule that compilers will always initalize
> uninitialized scheme values to zero?  Because I discovered a
> segfault just yesterday (in a different program) that was because
> of gcc [1] not initalizing a variable to 0.

The C runtime initializes static storage to binary zeros.  That is
guaranteed.  For automatic variables, all guesses are off.  The typical
multiuser operating system will initialize stack areas to zeros when
they get mapped the first time (uninitialized memory could leak
information), but only when the area is used the first time.  After
that, the values depend on the history of previous function calls.

> [1] or rather, the C standard does not specify that an uninitalized
> variable should be set to 0, so I do not blame gcc in the least; it
> was the programmer at fault.

The C standard guarantees binary zeros for statically allocated
uninitialized variables.

-- 
David Kastrup


_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to