digitalmars.D.learn - Another bug?
- Jack Applegame (24/24) Jan 30 2017 Code:
- Jack Applegame (20/20) Jan 30 2017 WORKAROUND:
- ag0aep6g (2/26) Jan 30 2017 Yup, looks like a (pretty bad) bug to me.
- Jack Applegame (1/1) Jan 30 2017 bug report: https://issues.dlang.org/show_bug.cgi?id=17128
- Yuxuan Shui (2/3) Jan 30 2017 LDC (2.070.2) has a different problem: the dtor is never called.
Code: 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.
Jan 30 2017
WORKAROUND: import std.stdio; struct Foo { int val = 0; ~this() { writefln("destruct %s", val); } } void bar(ARGS...)() { struct Tuple { ARGS args; alias args this; } Tuple args; args[0].val = 1; writefln("val = %s", args[0].val); } void main() { bar!Foo(); }
Jan 30 2017
On 01/30/2017 12:55 PM, Jack Applegame wrote:Code: 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.Yup, looks like a (pretty bad) bug to me.
Jan 30 2017
bug report: https://issues.dlang.org/show_bug.cgi?id=17128
Jan 30 2017
On Monday, 30 January 2017 at 12:40:44 UTC, Jack Applegame wrote:bug report: https://issues.dlang.org/show_bug.cgi?id=17128LDC (2.070.2) has a different problem: the dtor is never called.
Jan 30 2017