Bug 12419 – assertion failure in std.utf

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-20T02:19:00Z
Last change time
2014-04-23T19:32:15Z
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2014-03-20T02:19:24Z
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: [email protected](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.
Comment #1 by github-bugzilla — 2014-03-24T11:51:35Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/0f0511f81bcafb11488087c7d68cf1bb45ad4c21 fix issue 12419 Test that UTF-8 decoding yields a value in the valid range. UTF-8 may encode values beyond these covered by [0, 0x10FFFF]. https://github.com/D-Programming-Language/phobos/commit/3c92edeb3bab2bc60cbdb3f307e3fd8ca1d2f9bb Merge pull request #2038 from blackwhale/issue-12419 Fix issue 12419: assertion failure in std.utf
Comment #2 by monarchdodra — 2014-04-23T19:32:15Z
*** Issue 12616 has been marked as a duplicate of this issue. ***