I'd like to check a bit of info I need for Address Sanitizer checking.

The spec says [1]:
Use the destroy function to finalize an object by calling its destructor. The memory of the object is not immediately deallocated, instead the GC will collect the memory of the object at an undetermined point after finalization:
```
  class Foo { int x; this() { x = 1; } }
  Foo foo = new Foo;
  destroy(foo);
  assert(foo.x == int.init);  // object is still accessible
```

This tells me 2 things that I'd like to verify:
1. The destroyed memory is set to the type's `.init` value. (but the Ctor is not called)
2. It is _valid_ to access the memory after calling destroy.

Point 2 is worrying: what if there is a thread switch right after destroy, in which a GC collect happens?

Thanks,
  Johan

[1] https://dlang.org/spec/class.html#deallocators

Reply via email to