www.digitalmars.com         C & C++   DMDScript  

D - Question on 'out' parameter

reply Kazuhiro Inaba <ki kmonos.net> writes:
Hi, i have one question about 'out'.
I compiled the following D program,

//-------
import c.stdio;

void foo(out int bar)
{
}

int main( char[][] arg )
{
int bar = 3;
foo(bar);
printf( "%d", bar );
return 0;
}
//-------

and executing this, "3" was printed. But the online documentation (
http://www.digitalmars.com/d/function.html ) says that bar should be "0". Which
is the expected behavior?

--
k.inaba
Jan 11 2003
parent "Walter" <walter digitalmars.com> writes:
It should be 0. It's a bug.

"Kazuhiro Inaba" <ki kmonos.net> wrote in message
news:avqlfj$2inf$1 digitaldaemon.com...
 Hi, i have one question about 'out'.
 I compiled the following D program,

 //-------
 import c.stdio;

 void foo(out int bar)
 {
 }

 int main( char[][] arg )
 {
 int bar = 3;
 foo(bar);
 printf( "%d", bar );
 return 0;
 }
 //-------

 and executing this, "3" was printed. But the online documentation (
 http://www.digitalmars.com/d/function.html ) says that bar should be "0".
Which
 is the expected behavior?

 --
 k.inaba
Jan 12 2003