[Issue 4927] New: writefln silently ignores arguments not present in the format string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 23 15:34:22 PDT 2010


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

           Summary: writefln silently ignores arguments not present in the
                    format string
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-09-23 15:33:40 PDT ---
With dmd 2.049 this program:


import std.stdio: writefln;
void main() {
    writefln("%d", 1, 2);
}


Prints:
1


But in this case I expect a compile-time error (or equivalent run-time error if
the compiler is lazy and doesn't perform such very basic tests at
compile-time), because the format string doesn't contain the same things as the
given arguments.

In this case printing 12 is not good, because when a writefln is used, it's
better to avoid possible bugs to enforce that arguments and format string match
exactly.

See also bug 4458

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


More information about the Digitalmars-d-bugs mailing list