July 25, 2021 [Issue 22143] New: Throwable ctor doesn't increment chained exception's ref count | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22143 Issue ID: 22143 Summary: Throwable ctor doesn't increment chained exception's ref count Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody@puremagic.com Reporter: rmanth@gmail.com If you catch a dip1008 ref-counted throwable and pass it into the constructor of an `Error` or `Exception` the ref count isn't incremented. You have to assign via the `next` property to achieve this. ----------------------------------- module chain void main() { try { throw new Exception("reasons..."); } catch(Exception e1) { auto rc1 = e1.refcount(); auto e2 = new Exception("stuff...", e1); // should increment ref count assert(e1.refcount() == rc1+1); // Assertion failure } } ------------------------------------ dmd -preview=dip1008 -run chain.d core.exception.AssertError@chain.d(10): Assertion failure -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply