[Issue 24798] New: std.algorithm.substitute appears to be destroying an already destroyed value
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 6 10:51:46 UTC 2024
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 at puremagic.com
Reporter: issues.dlang at 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.
--
More information about the Digitalmars-d-bugs
mailing list