www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14136] New: std.uni.utfMatcher breaks safety

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

          Issue ID: 14136
           Summary: std.uni.utfMatcher breaks  safety
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: safe
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: code klickverbot.at

---
struct Oops {
pure:
    bool empty() {
        *cast(int*)0xcafebabe = 0xdeadbeef;
        return true;
    }

    Oops save()  property { return this; }
    char front;
    void popFront() {}
    char back;
    void popBack() {}
    ref char opIndex(size_t idx) { return front; }
    enum size_t length = 0;
    alias opDollar = length;
}

void main()  safe {
    import std.uni;
    auto m = utfMatcher!char(unicode.Number);
    Oops o;
    m.match(o);
}
---

Again, the reason is a  trusted template function taking an arbitrary range.

Source permalink (other match variants are affected too):
https://github.com/D-Programming-Language/phobos/blob/041db2d8fac2b1cf5169be7188ea537a01f27586/std/uni.d#L4767-L4787

Introduced in https://github.com/D-Programming-Language/phobos/pull/2020.

--
Feb 06 2015