Forked GC explained
Steven Schveighoffer
schveiguy at gmail.com
Mon Sep 5 18:35:02 UTC 2022
On 9/5/22 7:12 AM, frame wrote:
> And what if the programmer has no actual reference but wrongly forced a
> `free()` through a pointer cast?
https://dlang.org/spec/garbage.html#pointers_and_gc
* Do not store pointers into non-pointer variables using casts and other
tricks.
```d
void* p;
...
int x = cast(int)p; // error: undefined behavior
```
The garbage collector does not scan non-pointer fields for GC pointers.
Note that this does not require the forked GC to cause this problem.
-Steve
More information about the Digitalmars-d-learn
mailing list