[Issue 761] New: std.format.doFormat fails for items of a char[][] containing %s

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 28 12:22:10 PST 2006


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

           Summary: std.format.doFormat fails for items of a char[][]
                    containing %s
           Product: D
           Version: 0.178
          Platform: PC
               URL: http://www.digitalmars.com/webnews/newsgroups.php?art_gr
                    oup=digitalmars.D.announce&article_id=6505
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: lio at lunesu.com


#import std.stdio;
#void main() {
#   const char[][] x = ["%s","123"];
#   writefln(x);
#}

C:\dmd>dmd -run bug
[Error: std.format

This happens because doFormat is called recursively, once for each of the 
elements of the array. This means that there should never be any parsing for 
string elements, since there'll never be any 2nd argument to be formatted.

A possible fix (+patch) can be found at:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=6505

"Because the new doFormat takes the extra "bool parse" parameter, the fix is 
simple: invoke doFormat with parse set to false."


-- 



More information about the Digitalmars-d-bugs mailing list