Address of parameterless ref function
Timon Gehr
timon.gehr at gmx.ch
Sat Apr 9 09:59:06 PDT 2011
Whats the output of the following code supposed to be?
import std.stdio;
int a=0;
ref int g(){
writeln("called g");
return ++a;
}
void main(){
int function() f=&g;
writeln(cast(int)&a);
writeln(f());
writeln(f());
writeln(f());
}
The output using dmd 2.052
-144918776
called g
-144918776
called g
-144918776
called g
-144918776
This is certainly wrong, as it includes an IMPLICIT cast from int* to int, but
there are happening other strange things.
How to distinguish taking the address of a call to a parameterless ref
function from taking the address of the function itself anyways?
More information about the Digitalmars-d
mailing list