[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Uninitialized SCM variables

From: Phil Holmes
Subject: Re: Uninitialized SCM variables
Date: Wed, 17 Aug 2011 18:03:01 +0100

----- 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/ 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

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.

- 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.

Phil Holmes

reply via email to

[Prev in Thread] Current Thread [Next in Thread]