[Issue 19183] DIP1000 defeated if auto used instead of scope in variable declaration with template this member function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 21 10:56:00 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19183
--- Comment #4 from Atila Neves <atila.neves at gmail.com> ---
I made a mistake when I posted the code. This compiles but shouldn't (the only
difference is removing `scope` from the destructor).
I also surrounded the call to `free` with @trusted instead of the whole
constructor.
@safe:
const(int)* gInts;
void main() {
auto s = MyStruct(10);
gInts = s.ints;
}
struct MyStruct
{
import core.stdc.stdlib;
int* ints;
this(int size) @trusted { ints = cast(int*) malloc(size); }
~this() { () @trusted { free(ints); }(); }
scope ptr(this This)() { return ints; }
}
--
More information about the Digitalmars-d-bugs
mailing list