www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23488] New: std.format.sformat mishandles char ranges

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

          Issue ID: 23488
           Summary: std.format.sformat mishandles char ranges
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

struct R
{
    string s = "Ü";
    bool empty() { return s.length == 0; }
    char front() { return s[0]; }
    void popFront() { s = s[1 .. $]; }
}

void main()
{
    import std.format: sformat;
    char[2] buf;
    assert(sformat(buf, "%s", R()) == "Ü"); /* fails; should pass */
}

--
Nov 15 2022