Bug 19415 – return non-copyable struct fails if member function has return attribute
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-20T01:32:48Z
Last change time
2021-04-09T10:29:18Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Steven Schveighoffer
Comments
Comment #0 by schveiguy — 2018-11-20T01:32:48Z
struct S
{
int x;
S foo() return { return S(x); }
this(this) @disable;
}
S bar()
{
S s;
return s; // Error: struct `S` is not copyable because it is annotated with @disable
}
This fails to compile, unless you comment out the `foo` member. It seems completely unrelated, as it's never called.
This expectation of being able to return a local as an rvalue is paramount inside std.algorithm.move.
Comment #1 by razvan.nitu1305 — 2018-11-20T15:16:27Z
dlang/dmd pull request #12411 "[dmd-cxx] fix Issue 21813 - [REG-master] Bootstrap broken from dmd-cxx baseline" was merged into dmd-cxx:
- 31e20d648ba820f62c9fe5b88553dae834937a3c by RazvanN7:
[dmd-cxx] Fix Issue 19415 - return non-copyable struct fails if member function has return attribute
https://github.com/dlang/dmd/pull/12411