www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19738] New: std.range.choose assignment breaks safe-ty

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

          Issue ID: 19738
           Summary: std.range.choose assignment breaks  safe-ty
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: code klickverbot.at

Introduced in https://github.com/dlang/phobos/pull/6904:

---
import std.range;

struct EvilRange {
    enum empty = true;
    int front;
    void popFront()  safe {}
    auto opAssign(const ref EvilRange other){
        *(cast(uint*)0xcafebabe) = 0xdeadbeef;
        return this;
    }
}

void main()  safe {

    auto c1 = choose(true, EvilRange(), EvilRange());
    auto c2 = c1;
    c1 = c2;
}
---

--
Mar 14 2019