Bug 19931 – Missing error message when defining postblit, rvalue constructor and copy constructor

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2019-06-01T21:40:59Z
Last change time
2024-11-28T08:03:59Z
Keywords
pull
Assigned to
No Owner
Creator
Simen Kjaeraas
See also
https://issues.dlang.org/show_bug.cgi?id=23036, https://issues.dlang.org/show_bug.cgi?id=19871

Comments

Comment #0 by simen.kjaras — 2019-06-01T21:40:59Z
This compiles: struct S { this(S s) {} this(ref S s) {} this(this) {} } Commenting out this(this) {} yields the error message 'struct S may not define both a rvalue constructor and a copy constructor'. This kind of message should be there if all three are present, too.
Comment #1 by razvan.nitu1305 — 2019-06-04T09:58:36Z
This issue is invalid. Defining the postblit makes the compiler ignore the copy constructor, so the error goes away.
Comment #2 by simen.kjaras — 2019-06-04T11:07:09Z
Well, duh. What I'm saying it's just as wrong to define all three as it is to define two of them, and an error message should be present in both cases. We could perfectly well define that if there's an rvalue constructor and a copy constructor, one of them takes precedence and the other is ignored. Instead, we have an error message. The fact that we allow all three to be defined with no error message is confusing, and leads the programmer to believe there are no errors even though his carefully-crafted copy constructor is ignored.
Comment #3 by dlang-bot — 2019-06-18T12:50:49Z
@RazvanN7 created dlang/dmd pull request #10057 "Fix Issue 19931 - Missing error message when defining postblit, rvalue constructor and copy constructor" fixing this issue: - Fix Issue 19931 - Missing error message when defining postblit, rvalue constructor and copy constructor https://github.com/dlang/dmd/pull/10057
Comment #4 by dlang-bot — 2019-06-25T12:30:12Z
dlang/dmd pull request #10057 "Fix Issue 19931 - Missing error message when defining postblit, rvalue constructor and copy constructor" was merged into master: - 3509d2f017e62e41443ca09f98e071799bd3fe50 by RazvanN7: Fix Issue 19931 - Missing error message when defining postblit, rvalue constructor and copy constructor https://github.com/dlang/dmd/pull/10057