https://issues.dlang.org/show_bug.cgi?id=15586
--- Comment #5 from thomas.bock...@gmail.com --- > Keep in mind, though, that one *could* argue that casting an arbitrary value > to dchar already constitutes UB This has already been settled. It's not: http://forum.dlang.org/post/oionrfexehapzicgp...@forum.dlang.org > Generally, you probably shouldn't be casting stuff unless you know what > you're doing and are ready to handle the consequences when things go wrong. 1) No casting is required to trigger this bug. I was just giving you a simplified test case. Here's a slightly less simple one, without any casts: import std.stdio; void main() { import std.utf : toUTF8; dchar a = dchar.max; a += 1; char[4] buf = void; auto b = toUTF8(buf, a); import std.stdio; writeln(b); } 2) "If you don't want segfaults, don't cast stuff" is an awful solution to a hard crash in @safe code. There is no good reason that casts of basic numeric or character types should cause this kind of failure. --