[Issue 21358] conv.to array to string seems to lack nothrow
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 7 13:19:32 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=21358
--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
The problem is that to!() uses FormatSpec under the hood for types it doesn't
specialize on.
In particular it calls `toStr`, which itself uses this:
-----
import std.array : appender;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
auto w = appender!T();
FormatSpec!(ElementEncodingType!T) f;
formatValue(w, src, f);
return w.data;
-----
Internally FormatSpec tries to parse any format specs (like "%s") and does
other types of conversions like to!int which can throw exceptions, hence it
cannot be nothrow.
I think this issue can be fixed as part of the larger @nogc / nothrow plans in
https://forum.dlang.org/thread/qkfwgqslqnuyjgidldkv@forum.dlang.org.
--
More information about the Digitalmars-d-bugs
mailing list