[Issue 12419] New: assertion failure in std.utf

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 20 02:19:26 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12419

           Summary: assertion failure in std.utf
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2014-03-20 02:19:24 PDT ---
Test code:

import std.utf;

void main()
{
    char[4] val;
    val[0] = 0b1111_0111;
    val[1] = 0b1011_1111;
    val[2] = 0b1011_1111;
    val[3] = 0b1011_1111;
    size_t i = 0;
    dchar ch = decode(val[], i); //must have thrown exception
}

Instead:
core.exception.AssertError at std.utf(950): Assertion failure

The trick is that encoded value (0x1FFFFF) is way beyond the standard range
[0,0x10FFFF] and then the out contract of decode fails.

std.utf.decode must throw on 4 byte sequence with values above 0x10_FFFF.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list