[Issue 22680] @safe hole with destructors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 29 13:53:59 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22680
--- Comment #6 from Stanislav Blinov <stanislav.blinov at gmail.com> ---
(In reply to Dennis from comment #5)
> (In reply to Stanislav Blinov from comment #4)
> > There would be unwanted side effects. On a struct, for example, marking a
> > destructor scope would prevent you from returning instances of such struct.
>
> No, it only adds restrictions to the destructor's function body, not the
> destructor's caller.
Compile this with -dip1000:
@safe:
struct S
{
~this() scope {}
void* p;
}
S test()
{
S s;
return s; // Error: scope variable `s` may not be returned
}
void main()
{
}
--
More information about the Digitalmars-d-bugs
mailing list