Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 09, 2021 [Issue 22498] auto ref function with auto ref parameter causes noncopyable payload be cleaned twice | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22498 Tomáš Chaloupka <chalucha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|critical |normal --- Comment #1 from Tomáš Chaloupka <chalucha@gmail.com> --- I've found possible workaround. ``` auto ref unwrap(EX)(auto ref EX res) { static if (__traits(isRef, res)) { printf("unwrap(ref)\n"); return res.get(); } else { printf("unwrap(val)\n"); auto ret = res.get().move(); // < NRVO return ret; } } ``` Then with `Foo f = gen(42).unwrap;` It otputs: ``` ~this(0) ~this(0) ~this(0) unwrap(val) ~this(0) ~this(42) ``` But I'm still puzzled about what's wrong with the original one. -- |
November 12, 2021 [Issue 22498] auto ref function with auto ref parameter causes noncopyable payload be cleaned twice | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22498 Sebastiaan Koppe <mail@skoppe.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mail@skoppe.eu --- Comment #2 from Sebastiaan Koppe <mail@skoppe.eu> --- As have I commented on the newsgroup https://forum.dlang.org/post/zckdpsukzafedikiuaci@forum.dlang.org " It doesn't copy. It just destructs the same object twice... Ouch. Change the destructor to ~this() { printf("~this(%d)\n", n); n = 12; } and you'll see. " -- |
December 17, 2022 [Issue 22498] auto ref function with auto ref parameter causes noncopyable payload be cleaned twice | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22498 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
December 13 [Issue 22498] auto ref function with auto ref parameter causes noncopyable payload be cleaned twice | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22498 --- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20006 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation