Comment #0 by snarwin+bugzilla — 2022-12-14T19:07:08Z
As of DMD 2.101.0, the following program compiles and runs successfully to completion:
---
struct S
{
this(ref S)
{
assert(0);
}
}
void main()
{
S[] a = [ S() ];
S[] b = a ~ a;
}
---
This program should assert at runtime when evaluating the expression `a ~ a`, but does not, because the copy constructors of a's elements are not called.
If the copy constructor is changed to a postblit (`this(this)`), the program asserts at runtime, as expected.
See also issue 23556, which affects appending to an array (~=), and issue 20879, which affected .dup and .idup.
Comment #1 by razvan.nitu1305 — 2022-12-16T08:30:24Z