[Issue 20868] DIP1000: scope delegate triggers error in unsafe code and it shouldn't
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 14 08:16:57 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=20868
--- Comment #5 from Walter Bright <bugzilla at digitalmars.com> ---
To be specific, when compiled with -dip1000:
void scoped (scope void delegate() dg) {
static void delegate()[] dgs;
dgs ~= dg; // Error: scope variable `dg` may not be copied into allocated
memory
}
and there is no error without -dip1000.
The first thing to do is simplify:
void scoped (scope void* p) {
static void*[] px;
px ~= p;
}
which exhibits the same behavior. But let's try this:
void scoped (scope void* p) {
static void* px;
px = p;
}
which generates no error with or without -dip1000. Marking the function with
@safe yields:
Error: scope variable p is assigned to non-scope px
with or without -dip1000.
The examples must behave the same way. They don't, so which is right? The array
examples are wrong.
--
More information about the Digitalmars-d-bugs
mailing list