[Issue 17128] New: Wrong destructor call, if variables declared using tuple of types.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jan 30 04:39:31 PST 2017
https://issues.dlang.org/show_bug.cgi?id=17128
Issue ID: 17128
Summary: Wrong destructor call, if variables declared using
tuple of types.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: japplegame at gmail.com
import std.stdio;
struct Foo {
int val = 0;
~this() {
writefln("destruct %s", val);
}
}
void bar(ARGS...)() {
ARGS args;
args[0].val = 1;
writefln("val = %s", args[0].val);
}
void main() {
bar!Foo();
}
Excpected output:
val = 1
destruct 1
But got:
destruct 0
val = 1
It seems that the compiler destructs 'args' immediately after definition, not
at the end of the function.
--
More information about the Digitalmars-d-bugs
mailing list