On Wednesday, 2 August 2023 at 13:27:50 UTC, Steven Schveighoffer
wrote:
On 8/2/23 7:40 AM, Nick Treleaven wrote:
Presumably an allocation like `new T` (for a type with a @safe
constructor) can be made anywhere a call to `GC.collect` can
be made, which may trigger a collection. So why isn't
`GC.collect` marked @safe?
It should be. Maybe historical reasons?
One possible (but wrong) reason is that destructors can be
unsafe. But you are correct in that allocation can cause a
collection.
OK, thanks. I've made a pull to add `@safe` for enable, disable,
collect, minimize:
https://github.com/dlang/dmd/pull/15493/files
Now I'm wondering why those functions are marked `pure` - they
must affect the GC's bookkeeping state.