[Issue 8471] std.stdio.readf should be @trusted

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 30 09:22:09 PST 2017


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

--- Comment #11 from Andrei Alexandrescu <andrei at erdani.com> ---
Oh, sorry. The idea is to leave readf unqualified and let the compiler infer
whether it's safe or not.

In this particular case I see there's a simple solution - just add a constraint
to it making sure all parameters are pointers. Something like:

uint readf(Data...)(in char[] format, Data data)
if (allSatisfy!(isPointer, Data);

Then the only way to call readf is with pointers, which eliminates the
possibility of shenanigans.

--


More information about the Digitalmars-d-bugs mailing list