Thread overview
[Issue 626] New: std.format.doFormat accepts non-string arrays with any format specifier
Dec 02, 2006
d-bugmail
December 02, 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@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']);
}


-- 

October 11, 2009
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: -------
September 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=626


Andrei Alexandrescu <andrei@metalanguage.com> changed:

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


--- Comment #1 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-09-13 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: -------