digitalmars.D.bugs - [Issue 20424] New: A constructor with a value argument of the same
- d-bugmail puremagic.com (28/28) Dec 01 2019 https://issues.dlang.org/show_bug.cgi?id=20424
https://issues.dlang.org/show_bug.cgi?id=20424 Issue ID: 20424 Summary: A constructor with a value argument of the same type as being constructed should be an error Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com extern(C) void puts(const char*); struct S { this(S) // should be a compile time error { puts("works fine"); } } void main() { S a; S b = S(a); } It should call itself recursively and crash. The fact that it appears to run successfully is also a bug. Copy constructors must take their first argument by reference. https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1018.md --
Dec 01 2019