[Issue 10102] New: @disable incompletely implemented

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 16 23:23:38 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10102

           Summary: @disable incompletely implemented
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bugzilla at digitalmars.com


--- Comment #0 from Walter Bright <bugzilla at digitalmars.com> 2013-05-16 23:23:37 PDT ---
Many things are not checked for:
--------------------------
struct NotNull(T) {
    T p;

    alias p this;

    this(T p) {
        assert(p != null, "pointer is null");
        this.p = p;
    }

    @disable this();

    NotNull opAssign(T p) {
        assert(p != null, "assigning null to NotNull");
        this.p = p;
        return this;
    }
}

struct S {
    NotNull!(int *) m;
    // should fail: an explicit constructor must be required for S
}

void main() {
    int i;
    NotNull!(int*) n = &i;
    *n = 3;
    assert(i == 3);
    n = &i;
    n += 1;

    NotNull!(int*)[3] a;             // should fail
    auto b = new NotNull!(int*)[3];  // should fail
    S s = S();                       // should fail
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list