D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19931 - Missing error message when defining postblit, rvalue constructor and copy constructor
Summary: Missing error message when defining postblit, rvalue constructor and copy con...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-06-01 21:40 UTC by Simen Kjaeraas
Modified: 2024-11-28 08:03 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2019-06-01 21:40:59 UTC
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 RazvanN 2019-06-04 09:58:36 UTC
This issue is invalid. Defining the postblit makes the compiler ignore the copy constructor, so the error goes away.
Comment 2 Simen Kjaeraas 2019-06-04 11:07:09 UTC
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 Dlang Bot 2019-06-18 12:50:49 UTC
@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 Dlang Bot 2019-06-25 12:30:12 UTC
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