D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21836 - std.format: grouping may cause RangeError
Summary: std.format: grouping may cause RangeError
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-04-17 08:48 UTC by Berni44
Modified: 2021-04-24 08:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Berni44 2021-04-17 08:48:37 UTC
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]
Comment 1 Dlang Bot 2021-04-23 08:05:11 UTC
@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
Comment 2 Dlang Bot 2021-04-24 08:15:15 UTC
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