Make printf safe
Nick Treleaven
nick at geany.org
Wed Jul 17 09:20:23 UTC 2024
On Wednesday, 17 July 2024 at 08:58:56 UTC, IchorDev wrote:
> On Saturday, 13 July 2024 at 20:39:32 UTC, Walter Bright wrote:
>> The idea is printf is already largely safe:
>> [...]
>
> [`@safe` functions cannot perform pointer
> arithmetic](https://dlang.org/spec/function.html#safe-functions), but `printf` does because it indexes a `char*` (its first parameter).
The idea is to make certain calls of `printf` safe when the first
argument is a string literal:
```
char[] s;
printf("%s\n", s);
```
See https://forum.dlang.org/post/v775k1$1tmj$1@digitalmars.com.
More information about the dip.ideas
mailing list