The last assertion in the code below fails. This makes 1008 far less useful than it could be. Exceptions have error messages, and the only way to construct a useful message with runtime information is to allocate. Given that the purpose of dip1008 is to avoid the GC and still be able to use exceptions, the non error-prone way of doing this is to use an RAII string class.
However, that means that _d_delThrowable should call the class's destructor, which it doesn't right now, resulting in a either a leak or the programmer having to manually dispose of the memory.
---------------
class MyException: Exception {
static int numInstances;
this(string msg) {
super(msg);
++numInstances;
}
~this() {
--numInstances;
}
}
void main() {
assert(MyException.numInstances == 0);
try
throw new MyException("oops");
catch(MyException _)
assert(MyException.numInstances == 1);
assert(MyException.numInstances == 0);
}
---------------
% dmd -dip1008 -run exception.d
[email protected](21): Assertion failure
Comment #1 by iamthewilsonator — 2018-10-20T03:51:03Z