Out of scope access to a variable using stored pointer address, demonstration.

```
import std;

void outofcontext()
{
    writeln("Hello D ", associative);
    foreach (pointeraddress, information; associative)
    {
        writeln(*cast(string*)pointeraddress);
    }

}

static string[void* ] associative;

void main()
{
    writeln("Hello D ", associative);

    string variable = "hi";
    void* pointeraddress = &variable;
    associative[pointeraddress] = "someinformation";

    outofcontext();
}
```
https://run.dlang.io/is/QVgL1J
![](https://i.imgur.com/DZqXtj4.png)

Reply via email to