digitalmars.D.bugs - [Issue 20914] New: __xdtor bypasses function attributes
- d-bugmail puremagic.com (36/36) Jun 09 2020 https://issues.dlang.org/show_bug.cgi?id=20914
https://issues.dlang.org/show_bug.cgi?id=20914 Issue ID: 20914 Summary: __xdtor bypasses function attributes Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: timon.gehr gmx.ch DMD 2.092.0: import std.stdio, std.conv; import core.stdc.stdlib; extern(C++) class C{ ~this() nogc pure safe nothrow{ } } extern(C++) class D:C{ ~this(){ int[2] k; new int; writeln("impure"); k.ptr[1]=2; throw new Exception(""); } } void main() nogc pure nothrow{ enum size=__traits(classInstanceSize,C); auto p = malloc(size)[0..size]; C c = emplace!D(p); destroy(c); // calls D's destructor, but is annotated nogc, pure and nothrow free(p.ptr); } Not sure what's the best fix. Perhaps destructors of child classes should inherit the base class destructor attributes. (That would also allow solving issues with missing attributes on `destroy` for classes inheriting from Object.) --
Jun 09 2020