Bug 16661 – [REG2.072] std/format.d(1070): Incorrect format specifier: .2f for wstring and dstring
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-11-05T01:24:00Z
Last change time
2017-01-16T23:25:02Z
Keywords
pull
Assigned to
code
Creator
ttanjo
Comments
Comment #0 by ttanjo — 2016-11-05T01:24:27Z
I reproduced it on Linux 64bit systems.
The following code throws an exception at runtime when using dmd 2.072.0 or later.
When I use older version of dmd, this code run without exceptions.
=== sample.d
void main(string[] args)
{
import std.format;
assert(format("%.2f"d, 0.4) == "0.40");
}
===
How to reproduce:
===
$ dmd sample.d
$ ./sample
===
Expected:
./sample successfully exits without any outputs.
Actual:
./sample shows the following message:
=========
object.Exception@/home/tomoya/.denv/versions/dmd-trunk/linux/bin64/../../src/phobos/std/format.d(1070): Incorrect format specifier: .2f
----------------
??:? pure @safe void std.format.FormatSpec!(dchar).FormatSpec.fillUp() [0x43e24e]
??:? pure @safe bool std.format.FormatSpec!(dchar).FormatSpec.writeUpToNextSpec!(std.array.Appender!(immutable(dchar)[]).Appender).writeUpToNextSpec(std.array.Appender!(immutable(dchar)[]).Appender) [0x440487]
??:? @safe uint std.format.formattedWrite!(std.array.Appender!(immutable(dchar)[]).Appender, dchar, double).formattedWrite(std.array.Appender!(immutable(dchar)[]).Appender, const(dchar[]), double) [0x43cc67]
??:? @safe immutable(dchar)[] std.format.format!(dchar, double).format(const(dchar[]), double) [0x43c6c6]
??:? _Dmain [0x43c64a]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x44c4b2]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44c3f8]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x44c46e]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44c3f8]
??:? _d_run_main [0x44c372]
??:? main [0x44a06d]
??:? __libc_start_main [0x535b0290]
=========
When I use "%.2f" instead of "%.2f"d, it runs without exceptions.
When I use "%.2f"w or "%.2f"d, it throws an exception.