Automatic void initialization
Jason House
jason.james.house at gmail.com
Sun May 31 17:26:53 PDT 2009
Fractal wrote:
> Hello
>
> if I have the following code:
>
> int foo;
> foo = 5;
>
> When the variable foo is declared, it is initialized to int.init, or has
> garbage contents until it is assigned?
>
> Thanks
D will always initialize variables unless you explicitly tell it not to.
(although a smart compiler may optimize certain cases)
Here's how to get foo initialized to garbage:
int foo = void;
foo = 5;
More information about the Digitalmars-d
mailing list