www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: deewiant 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']);
}


-- 
Dec 02 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=626


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=626


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



20:26:11 PDT ---
writefln("%d", [1,2,3]) works as designed - arrays pass down the format spec to
each of their elements. http://www.dsource.org/projects/phobos/changeset/1998
takes care of the rest.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 13 2010