stack frame & dangling pointer weirdness

Alain De Vos devosalain at ymail.com
Thu Apr 21 05:49:12 UTC 2022


Following program:
```
import std.stdio;

void main() @trusted
{

int *p=null;
void myfun(){
	int x=2;
	p=&x;
	writeln(p);
	writeln(x);
}
myfun();
*p=16;
writeln(p);
writeln(*p);
}
```

outputs :
7FFFFFFFDFAC
2
7FFFFFFFDFAC
32767

I don't understand why. Would it be possible to explain  ?


More information about the Digitalmars-d-learn mailing list