www.digitalmars.com         C & C++   DMDScript  

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


          Issue ID: 20669
           Summary: Deprecation when passing string length as printf
           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