[Issue 16054] New: can break immutable with std.typecons.Rebindable

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 21 15:01:37 PDT 2016


          Issue ID: 16054
           Summary: can break immutable with std.typecons.Rebindable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: ag0aep6g at gmail.com

import std.typecons: Rebindable;

class C
    int x;
    this(int x) pure { this.x = x; }

void main()
    Rebindable!(immutable C) ic = new immutable C(1);

    immutable(C)* p = &ic.get();
    assert(p.x == 1); /* passes */
    scope (exit) assert(p.x == 1); /* fails */

    ic = new immutable C(2);

As far as I see, Rebindable can't be allowed to return a reference to its
tail-immutable payload.


More information about the Digitalmars-d-bugs mailing list