February 06, 2016 [Issue 15648] New: Destructor constness doesn't take member destructor attributes into account | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15648 Issue ID: 15648 Summary: Destructor constness doesn't take member destructor attributes into account Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Keywords: rejects-valid Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: Marco.Leise@gmx.de I'm unable to implement an @nogc hash table that has immutable keys that have dtors and contain members with dtors. Here is the reduced version of such a structure: struct HashTable { immutable(Key)* keys; ~this() { destroy( keys[0] ); } } struct Key { KeyData data; ~this() const {} } struct KeyData { ~this() const {} } The compiler will complain: Error: mutable method main.Key.~this is not callable using a immutable object Error: template instance object._destructRecurse!(immutable(Key)) error instantiating This seems to come from calling an aggregated non-const destructor and I don't know of a feasible workaround. The ones I know of are: 1) remove immutability from keys and const from dtors 2) merge KeyData's dtor into that of Key (but Key is a generic templated wrapper struct) -- |
Copyright © 1999-2021 by the D Language Foundation