www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19383] New: AA insertion is not exception-safe

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 puremagic.com
          Reporter: stanislav.blinov 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]
}

--
Nov 09 2018