std.utf: use throw UTFException instead of assert(0) in stride, etc

Jonathan M Davis jmdavisProg at gmx.com
Tue Dec 10 16:45:08 PST 2013


On Tuesday, December 10, 2013 15:52:06 Timothee Cour wrote:
> in std.utf shouldn't we throw UTFException instead of assert(0) in stride,
> etc ?

std.utf only uses assert(0) when that code should be unreachable. It's used to 
catch bugs in the implementation, not in a function's input. If anything in 
std.utf ever hits an assert(0), it's a bug. A UTFException _is_ thrown when a 
std.utf function encounters invalid Unicode. It's certainly possible that 
there's a bug involving assert(0) in std.utf, but there shouldn't be any case 
in all of Phobos where an assert(0) would actually be hit.

- Jonathan M Davis


More information about the Digitalmars-d mailing list