[Issue 17381] New: Checked format string is permissive after floating point argument

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun May 7 04:49:14 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17381

          Issue ID: 17381
           Summary: Checked format string is permissive after floating
                    point argument
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: acehreli at yahoo.com

A float argument eliminates subsequent orphan argument checks.

import std.format;

void main() {
    static assert(!__traits(compiles, format!"%s"(1.5, 2)));
}

static assert fails because the expression should not compile because there is
an orphan argument. (In real code, it would compile but throw FormatException
at runtime.)

Replacing %s with %f does not make a difference; it still compiles.

You can have more arguments before the floating point argument; it always
breaks the subsequent orphan argument checks.

Ali

--


More information about the Digitalmars-d-bugs mailing list