[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Uninitialized SCM variables
From: |
David Kastrup |
Subject: |
Re: Uninitialized SCM variables |
Date: |
Wed, 17 Aug 2011 19:26:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Graham Percival <address@hidden> writes:
> On Wed, Aug 17, 2011 at 05:53:40AM -0600, Carl Sorensen wrote:
>> \On 8/16/11 10:25 PM, "Dan Eble" <address@hidden> 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
- Re: Uninitialized SCM variables, (continued)
- Re: Uninitialized SCM variables, Carl Sorensen, 2011/08/17
- Re: Uninitialized SCM variables, Reinhold Kainhofer, 2011/08/17
- Re: Uninitialized SCM variables, David Kastrup, 2011/08/17
- Re: Uninitialized SCM variables, Graham Percival, 2011/08/17
- Re: Uninitialized SCM variables, Phil Holmes, 2011/08/17
- Re: Uninitialized SCM variables, David Kastrup, 2011/08/17
- Re: Uninitialized SCM variables, Dan Eble, 2011/08/18
- Re: Uninitialized SCM variables, David Kastrup, 2011/08/18
- Re: Uninitialized SCM variables, Reinhold Kainhofer, 2011/08/18
- Re: Uninitialized SCM variables, Carl Sorensen, 2011/08/18
- Re: Uninitialized SCM variables,
David Kastrup <=
- Re: Uninitialized SCM variables, Graham Percival, 2011/08/17