[Issue 23523] Allow User-Defined Implicit Conversions for const/immutable containers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 4 18:19:34 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23523

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #2 from Nick Treleaven <nick at geany.org> ---
> Similarly, allow `immutable type!T` to convert to `type!(immutable T)`

That isn't always safe:

struct S(T)
{
    int* p;
}

void main()
{
    auto s = S!(immutable int)();
    immutable si = S!int();
    s = si; // currently an error
    *s.p = 4;
    assert(*si.p == 0); // fails
}

--


More information about the Digitalmars-d-bugs mailing list