<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">I filed a bug report: </span><a href="https://issues.dlang.org/show_bug.cgi?id=12923" target="_blank" style="font-family:arial,sans-serif;font-size:13px">https://issues.dlang.org/show_bug.cgi?id=12923</a><span style="font-family:arial,sans-serif;font-size:13px"> : "UTF exception in stride even though passes validate"</span><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">and then a proposed fix. The fix still passes unittests and also solves the bug, however I'm not sure whether it is correct: is the behavior of strideImpl correct or is the old behavior of decodeImpl correct?</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">TL;DR:</div><div style="font-family:arial,sans-serif;font-size:13px">auto fst=str.front;<br></div>
<div style="font-family:arial,sans-serif;font-size:13px"><div>immutable msbs = 7 - bsr(~fst);</div><div>if (msbs < 2 || msbs > 6) throw invalidUTF();</div></div></div>