Automatic void initialization
Walter Bright
newshound1 at digitalmars.com
Tue Jun 2 03:25:38 PDT 2009
Fractal wrote:
> 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?
Here's the easy way to find out:
int bar()
{ int foo;
foo = 5;
return foo;
}
compile with:
dmd -c test -O -release
and disassemble with:
obj2asm test.obj
to show the generated code is:
_D4test3barFZi comdat
mov EAX,5
ret
More information about the Digitalmars-d
mailing list