October 06 [Issue 24798] New: std.algorithm.substitute appears to be destroying an already destroyed value | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24798 Issue ID: 24798 Summary: std.algorithm.substitute appears to be destroying an already destroyed value Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: issues.dlang@jmdavisProg.com This code fails the assertion in the destructor: --- void main() { import std.algorithm.comparison : equal; import std.algorithm.iteration : substitute; static struct S { int val; ~this() { assert(val != 99); val = 99; } } auto arr = [S(0), S(1), S(2), S(3)]; assert(equal(arr.substitute(S(1), S(42)), [S(0), S(42), S(2), S(3)])); } --- So, it would appear that substitute is somehow destroying an already destroyed value. -- |
Copyright © 1999-2021 by the D Language Foundation