Thread overview
[Issue 15648] Destructor constness doesn't take member destructor attributes into account
Jul 02, 2017
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
July 02, 2017
https://issues.dlang.org/show_bug.cgi?id=15648

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
I believe the operation destroy(x) where x is an immutable value type was never
supported, as part of destroy's operation is to clobber the value of x with its
.init value - see object.d, the `void destroy(T)(ref T obj) if (is(T ==
struct))` overload.

Changing the destroy() call with an explicit invocation of the inclusive
destructor (`keys[0].__xdtor();`) does seem to illustrate the problem better, I
think - the inclusive destructor should have its constness inferred from the
destructors it calls:

$ cat test.d
struct HashTable
{
    immutable(Key)* keys;

    ~this()
    {
        keys[0].__xdtor();
    }
}

struct Key
{
    KeyData data;
    ~this() const {}
}

struct KeyData
{
    ~this() const {}
}

$ dmd -o- test.d
test.d(7): Error: mutable method test.Key.~this is not callable using a
immutable object

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15648

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 13
https://issues.dlang.org/show_bug.cgi?id=15648

--- Comment #2 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17746

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--