[Issue 24800] New: pragma(printf) gives me the wrong fix

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 8 15:53:52 UTC 2024


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

          Issue ID: 24800
           Summary: pragma(printf) gives me the wrong fix
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at gmail.com

```d
printf("%s", 5);
```

produces the error:

```
Deprecation: argument `5` for format specification `"%s"` must be `char*`, not
`int`
```

But the thing is, what if the 5 is not the problem? What if the problem is the
%s?

I propose the error message gets changed to:

```
Deprecation: argument `5` of type `int` does not match format specification
`"%s"`. `"%s"` requires a `char*` parameter; `int` may be printed with `"%d"`.
```

Possibly, the compiler could list all the options for printing `int`, but this
is enough to tell the user how to fix the problem.

--


More information about the Digitalmars-d-bugs mailing list