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.
Comment #1 by ttanjo — 2016-11-09T12:23:16Z
Comment #2 by code — 2016-11-16T23:40:37Z
*** Issue 16676 has been marked as a duplicate of this issue. ***
Comment #3 by code — 2016-11-16T23:43:40Z
Comment #4 by github-bugzilla — 2016-11-17T08:56:25Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/ce85fd60a9fe3819907857b487f65bd977ca1f26 fix Issue 16661 - failing dstring/wstring format string - fix incorrect pointer diff computation introduced by PR #4427 commit 2be035584f31131ebd3e2123b19f457c326d070d https://github.com/dlang/phobos/commit/9707f00e22102d692c56bc8c805d841a613fdf06 Merge pull request #4904 from MartinNowak/fix16661 fix Issue 16661 - failing dstring/wstring format string
Comment #5 by github-bugzilla — 2016-12-07T16:09:08Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/ce85fd60a9fe3819907857b487f65bd977ca1f26 fix Issue 16661 - failing dstring/wstring format string https://github.com/dlang/phobos/commit/9707f00e22102d692c56bc8c805d841a613fdf06 Merge pull request #4904 from MartinNowak/fix16661
Comment #6 by github-bugzilla — 2016-12-27T13:11:28Z
Commits pushed to scope at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/ce85fd60a9fe3819907857b487f65bd977ca1f26 fix Issue 16661 - failing dstring/wstring format string https://github.com/dlang/phobos/commit/9707f00e22102d692c56bc8c805d841a613fdf06 Merge pull request #4904 from MartinNowak/fix16661
Comment #7 by github-bugzilla — 2017-01-16T23:25:02Z
Commits pushed to newCTFE at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/ce85fd60a9fe3819907857b487f65bd977ca1f26 fix Issue 16661 - failing dstring/wstring format string https://github.com/dlang/phobos/commit/9707f00e22102d692c56bc8c805d841a613fdf06 Merge pull request #4904 from MartinNowak/fix16661