www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19415] New: return non-copyable struct fails if member

https://issues.dlang.org/show_bug.cgi?id=19415

          Issue ID: 19415
           Summary: return non-copyable struct fails if member function
                    has return attribute
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schveiguy yahoo.com

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.

--
Nov 19 2018