assert(format!"%-5,1g"(0.0) == "0 "); Instead it throws: core.exception.RangeError@/usr/include/dmd/phobos/std/format/internal/write.d(656): Range violation ---------------- ??:? _d_arrayboundsp [0x563fc0971eed] ??:? @safe void std.format.internal.write.formatValueImpl!(std.stdio.File.LockingTextWriter, double, char).formatValueImpl(ref std.stdio.File.LockingTextWriter, double, scope ref const(std.format.spec.FormatSpec!(char).FormatSpec)) [0x563fc09678a8] ??:? @safe void std.format.write.formatValue!(std.stdio.File.LockingTextWriter, double, char).formatValue(ref std.stdio.File.LockingTextWriter, ref double, scope ref const(std.format.spec.FormatSpec!(char).FormatSpec)) [0x563fc0967107] ??:? @safe uint std.format.write.formattedWrite!(std.stdio.File.LockingTextWriter, char, double).formattedWrite(ref std.stdio.File.LockingTextWriter, scope const(char[]), double) [0x563fc0966270] ??:? @safe void std.stdio.File.writefln!(char, double).writefln(in char[], double) [0x563fc0965ef2] ??:? @safe void std.stdio.writefln!(char, double).writefln(in char[], double) [0x563fc0965e7a] ??:? @safe void std.stdio.writefln!("%-5,1g", double).writefln(double) [0x563fc09523cf] ??:? _Dmain [0x563fc0951b8f]
@berni44 created dlang/phobos pull request #8000 "std.format: Make formatting 0.0 100% @nogc." fixing this issue: - Fix Issue 21836 - std.format: grouping may cause RangeError https://github.com/dlang/phobos/pull/8000
dlang/phobos pull request #8000 "std.format: Make formatting 0.0 100% @nogc." was merged into master: - fe6c6b369f76cac38c20ab25bc4f8fcb77259fba by berni44: Fix Issue 21836 - std.format: grouping may cause RangeError https://github.com/dlang/phobos/pull/8000