www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20669] New: Deprecation when passing string length as printf

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

          Issue ID: 20669
           Summary: Deprecation when passing string length as printf
                    argument
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

The lenght of a string can be passed as an additional argument preceding the
pointer. But DMD issues a warning about missmatched argument types.

-------------------------------------

void main()
{
    import core.stdc.stdio : printf;
    string s = "Hello, World";
    printf("%.s", s.length, &s[0]);
}

-------------------------------------

print.d(5): Deprecation: argument s.length for format specification "%.s" must
be char*, not uint

--
Mar 11 2020