D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19415 - return non-copyable struct fails if member function has return attribute
Summary: return non-copyable struct fails if member function has return attribute
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-11-20 01:32 UTC by Steven Schveighoffer
Modified: 2021-04-09 10:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2018-11-20 01:32:48 UTC
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 RazvanN 2018-11-20 15:16:27 UTC
PR: https://github.com/dlang/dmd/pull/8983
Comment 2 github-bugzilla 2018-11-22 06:15:20 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/487a8c5f725f831f47e96c7417d50ed765daa22b
Fix Issue 19415 - return non-copyable struct fails if member function has return attribute

https://github.com/dlang/dmd/commit/cba9e0bd80cc58919efee1a08cb49ecb087b2595
Merge pull request #8983 from RazvanN7/Issue_19415

Fix Issue 19415 - return non-copyable struct fails if member function has return attribute
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Comment 3 Dlang Bot 2021-04-09 10:29:18 UTC
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