digitalmars.D.bugs - [Issue 23557] New: Array concatenation ignores copy constructor
- d-bugmail puremagic.com (36/36) Dec 14 2022 https://issues.dlang.org/show_bug.cgi?id=23557
https://issues.dlang.org/show_bug.cgi?id=23557 Issue ID: 23557 Summary: Array concatenation ignores copy constructor Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com 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. --
Dec 14 2022