Bug 20914 – __xdtor bypasses function attributes

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-09T16:41:47Z
Last change time
2024-12-13T19:09:09Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#19719 →

Comments

Comment #0 by timon.gehr — 2020-06-09T16:41:47Z
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.)
Comment #1 by timon.gehr — 2020-06-09T16:48:55Z
Also see issue 15246.
Comment #2 by robert.schadek — 2024-12-13T19:09:09Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19719 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB