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

--- Comment #4 from Atila Neves <atila.ne...@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; }
}

--

Reply via email to