www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21836] New: std.format: grouping may cause RangeError

https://issues.dlang.org/show_bug.cgi?id=21836

          Issue ID: 21836
           Summary: std.format: grouping may cause RangeError
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla bernis-buecher.de

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]

--
Apr 17