On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
Dub(DMD 2.099.1) builds and runs the following code without a
warning.
import std.stdio;
import core.stdc.stdlib;
@live
void test()
{
int* p = cast(int*) malloc(32);
p = cast(int*) malloc(32);
free(p);
}
void main()
{
test();
writeln("???");
}
Isn't it supposed to trigger an error according to the doc
(https://dlang.org/spec/ob.html)?
@live void test()
{
auto p = allocate();
p = allocate(); // error: p was not disposed of
release(p);
}
You need to use the flag `-preview=dip1021`
test.d(8,30): Error: variable `test.test.p` assigning to Owner
without disposing of owned value