Thread overview
[Issue 21692] Non-mutable extern(D) scope class instances cannot be created.
Mar 08, 2021
kinke
May 30, 2022
Nick Treleaven
March 08, 2021
https://issues.dlang.org/show_bug.cgi?id=21692

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #1 from kinke <kinke@gmx.net> ---
This seems caused by `scope` allocations for (D) classes getting an implicit `delete stackConstD`, while C++ classes don't. Which is probably a bug in its own right.

The `delete` expression is deprecated; it resets the pointer to null, that's why it cannot be const. An updated lowering could use `destroy()` instead (it's only about calling the dtor/finalizer AFAICT), for C++ classes too, which should make it work with const as well (without dtor or with a const dtor).

--
March 08, 2021
https://issues.dlang.org/show_bug.cgi?id=21692

--- Comment #2 from thomas.bockman@gmail.com ---
(In reply to kinke from comment #1)
> This seems caused by `scope` allocations for (D) classes getting an implicit `delete stackConstD`, while C++ classes don't. Which is probably a bug in its own right.

Good catch! I filed a separate bug for that:
    https://issues.dlang.org/show_bug.cgi?id=21693

> The `delete` expression is deprecated; it resets the pointer to null, that's why it cannot be const. An updated lowering could use `destroy()` instead (it's only about calling the dtor/finalizer AFAICT), for C++ classes too, which should make it work with const as well (without dtor or with a const dtor).

Yes, that is how it should work.

--
May 30, 2022
https://issues.dlang.org/show_bug.cgi?id=21692

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nick@geany.org
         Resolution|---                         |DUPLICATE

--- Comment #3 from Nick Treleaven <nick@geany.org> ---


*** This issue has been marked as a duplicate of issue 19272 ***

--