https://d.puremagic.com/issues/show_bug.cgi?id=11721
--- Comment #1 from Kenji Hara <[email protected]> 2013-12-14 08:38:56 PST --- Until 2.063, std.utf.toUTFindex was non-template function. In each release, Phobos library is built with -release switch, so the asserts in non-template code is always removed. So, std.utf.toUTFindex had called release version of std.utf.stride, and it did not throw AssertError "Past the end of the UTF-8 sequence". But, stride function is @safe function, so array indexing was always checked boundaries, and could throw RangeError. In 2.064, std.utf.toUTFindex was changed to template function. https://github.com/D-Programming-Language/phobos/commit/87a2ee7f4d4e4959cf4db9a1710beac67c00129c#diff-27410a0be96392a06647e61c73131b64L882 So, if you compile your code without -release, the assertion is properly checked and it throws AssertError. If you compile the code with -release, the whole execution still succeeds with 2.064 and git-head. The main point is, today most of Phobos funcitons have no specifications against erroneous inputs. In this case, if you give invalid index for std.utf.stride via std.utf.toUTFindex, what happens is "implementation-dependent". (Note: std.utf.toUTFindex is marked as @safe, so it won't occur "undefined behavior", but it is not relevant with this issue.) The most better way I think is, changing your unittest code to assertThrown!Error(a.slice(2,8)); -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
