In Phobos' std/utf.d there's a unittest:
unittest // invalid start bytes
{
import std.exception: assertThrown;
immutable char[] invalidStartBytes = [
//0b1111_1000, // indicating a sequence length of 5
0b1111_1100, // 6
0b1111_1110, // 7
0b1111_1111, // 8
0b1000_0000, // continuation byte
];
foreach(c; invalidStartBytes)
assertThrown!UTFException(stride([c]));
}
Uncommenting the first element of the array makes the unittest fail. Actually uncommenting that but commenting another element of the array makes the unittest pass. The error cannot be reproduced by taking the unittest out.