[Issue 19383] New: AA insertion is not exception-safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 9 19:11:40 UTC 2018


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

          Issue ID: 19383
           Summary: AA insertion is not exception-safe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: stanislav.blinov at gmail.com

void main() {
    static struct S {
        bool cond;
        this(this) {
            if (cond) throw new Exception("failure");
        }
    }
    import std.exception;
    S[int] aa;
    assertThrown(aa[1] = S(true)); // or assertThrown(aa.require(1, S(true)));
    assert(aa.keys.length == 0); // fails, aa.keys is now [1]
}

--


More information about the Digitalmars-d-bugs mailing list