First Draft: Making printf @safe

Nick Treleaven nick at geany.org
Sat Aug 3 11:27:19 UTC 2024


On Friday, 2 August 2024 at 16:39:19 UTC, claptrap wrote:
> On Wednesday, 17 July 2024 at 00:42:03 UTC, Walter Bright wrote:
>> https://github.com/WalterBright/documents/blob/ed4f1b441e71b5ac5e23a54e7c93e68997981e9a/SafePrintf.md
>
> Why not just make a @safe version of printf, and have a 
> compiler error point people at it if they call unsafe printf 
> from safe code?

This DIP doesn't only apply to C's printf, it (potentially) 
applies to other pragma(printf) functions. AIUI a major 
motivation for it is dmd's frontend which has a lot of calls to 
its own extern(C) functions with printf formatting strings and C 
varargs. (I'd be interested in seeing an alternative proposal too 
on how to make those calls safe without this DIP, whilst still 
compiling with GDC & LDC).


More information about the dip.development mailing list