[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Uninitialized SCM variables
From: |
Dan Eble |
Subject: |
Re: Uninitialized SCM variables |
Date: |
Thu, 18 Aug 2011 01:32:31 -0400 |
On 2011-08-17, at 13:03 , Phil Holmes wrote:
> ----- Original Message ----- From: "Graham Percival" <address@hidden>
> To: "Carl Sorensen" <address@hidden>
> Cc: "lilypond-devel Development" <address@hidden>
> Sent: Wednesday, August 17, 2011 5:48 PM
> Subject: Re: Uninitialized SCM variables
>
>
>> 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.
>>
>> [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.
>>
>> Cheers,
>> - Graham
>
> In C-style languages, uninitialised variable are uninitialised and therefore
> have an indeterminant value. Hence the danger of uninitialised pointers.
> Some other languages do initialise them to 0 - visual basic is an example. In
> more modern languages, (c# is one I'm familiar with) the compile fails if a
> variable is not explicitly initialised.
Backing up… I believe the compiler will initialize the bits in the
aforementioned variables to zero, but is zero a desirable default for SCM
variables in general, and these in particular?
It also just sank in that in another thread there was a statement that treating
a SCM as a boolean is "very wrong". That would include a number of lines in
ly_property_lookup_stats and note_property_access that use these variables.
--
Dan