[Issue 20424] New: A constructor with a value argument of the same type as being constructed should be an error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 2 01:44:29 UTC 2019
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 at puremagic.com
Reporter: bugzilla at 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
--
More information about the Digitalmars-d-bugs
mailing list