[Issue 626] New: std.format.doFormat accepts non-string arrays with any format specifier

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 2 11:37:33 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=626

           Summary: std.format.doFormat accepts non-string arrays with any
                    format specifier
           Product: D
           Version: 0.175
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com


import std.stdio;

void main() {
        int[] x = [1,2,3];
        int[3] y = [1,2,3];
        int* z = [1,2,3];

        // work, incorrectly
        writefln("%3.2f", [1,2,3]);
        writefln("%3.2f", x);
        writefln("%3.2f", y);
        writefln("%d", [1,2,3]);
        writefln("%d", x);
        writefln("%d", y);

        writefln("--");

        // fail, correctly
        writefln("%3.2f", z);
        writefln("%d", z);
        writefln("%3.2f", ['f','o','o']);
}


-- 




More information about the Digitalmars-d-bugs mailing list