Escape Analysis & Owner Escape Analysis

IchorDev zxinsworld at gmail.com
Wed Sep 4 14:28:49 UTC 2024


On Tuesday, 3 September 2024 at 03:00:20 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> An example of this is with a global, in the case of a variable 
> thread local storage, it is possible in fully ``@safe`` code 
> with DIP1000 turned on to cause a segfault.
>
> ```d
> import std;
>
> int* tlsGlobal;
>
> @safe:
>
> void main() {
>     tlsGlobal = new int(2);
>     assert(*tlsGlobal == 2);
>
>     toCall();
>     assert(*tlsGlobal == 2); // Segfault
> }
>
> void toCall() {
>     tlsGlobal = null;
> }
> ```

But aren’t segfault always meant to be @safe anyway?
```d
int* x;
void main() @safe{
   auto y = *x;
}
```


More information about the dip.ideas mailing list