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