[Issue 18172] std.getopt should allow taking parameters by `ref` (like std.format.formattedRead), s.t. it can be used in @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 15 13:08:05 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18172
--- Comment #4 from Jack Stouffer <jack at jackstouffer.com> ---
(In reply to Jonathan M Davis from comment #3)
> I'd suggest looking into how DIP 1000 can fix this problem without needing
> ref, since with DIP 1000, taking the address of a local variable isn't
> necessarily @system.
Despite marking the parameters as scope and using `@safe` to check for any
security holes, creating a scoped pointer still yields an error
=====
@safe unittest
{
auto args = ["prog", "--foo", "-b"];
bool foo;
bool bar;
scope bool* f = &foo;
scope bool* b = &bar;
auto rslt = getopt(args, "foo|f", "Some information about foo.", f,
"bar|b",
"Some help message about bar.", b);
}
=====
std/getopt.d(452): Error: cannot take address of local foo in @safe function
__unittest_L446_C7
std/getopt.d(453): Error: cannot take address of local bar in @safe function
__unittest_L446_C7
--
More information about the Digitalmars-d-bugs
mailing list