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

Dennis <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Dennis <[email protected]> ---
I would not want to rely on compiler magic to rewrite a faulty format string
into a 
correct one. You even said yourself:

> I used to write macros in C named "printf" that would muck about with the 
> arguments, 
> add some logic, then call the real printf. After a few years I got tired of 
> them, 
> and put them in a bag with some rocks and threw it in the swamp.

https://forum.dlang.org/post/[email protected]

> It's kinda trivially obvious that someone can write their own functions to do 
> things, but pretending it is printf by naming it printf just puts a layer of 
> confusion in for the reader. printf is so ubiquitous that it brings 
> expectations when saying printf can be called that printf is actually being 
> called, rather than some intermediary one must write oneself.

https://forum.dlang.org/post/[email protected]

This is essentially such an intermediary function, only it's always inlined 
and implemented in the compiler. Ways this could backfire are:

- The code is compiled with an older D compiler that doesn't apply the fix
- printf arguments are copied to a third party 'my_printf' function that is 
  not annotated with pragma(printf)
- Someone unaware of D's printf magic translates D code to C 

Proposing the correct format specifier for the type (instead of only the
correct 
type for the format specifier) in the error message seems like a good idea.

--

Reply via email to