www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20534] New: std.format: %r on boolean gives wrong result


          Issue ID: 20534
           Summary: std.format: %r on boolean gives wrong result
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla d-ecke.de

The output of %r on booleans gives 4 bytes, not only one, because the bool is
cast to an int before it is formatted. This is inconsistent with other uses of
%r (which is yet undocumented).

void main()
    import std.format : format;

    assert(format("%r",false) == "\0"); // fails

Jan 26 2020