ldc
ldc copied to clipboard
Dtor not called on variable with UDA applied
In the testcase below, the dtor of x is not called when a UDA is applied. DMD and GDC do call the dtor, but LDC does not. The frontend AST indeed does not show x.~this() when the UDA is applied, but magically DMD does call the dtor (correct), and LDC does not (incorrect).
import std.stdio;
struct RAII
{
int i;
this(int a) { i = a; }
~this() {
writeln("dtor", i);
}
}
struct someUDA {}
void foo() {
@someUDA // comment out to have the dtor run.
auto x = RAII(1);
}
void main() {
foo();
}