https://issues.dlang.org/show_bug.cgi?id=19317
Issue ID: 19317 Summary: dip1008 doesn't call the throwable's destructor in _d_delThrowable Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: atila.ne...@gmail.com 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 core.exception.AssertError@exception.d(21): Assertion failure --