www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12686] New: Struct invariant prevents NRVO

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

          Issue ID: 12686
           Summary: Struct invariant prevents NRVO
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bugzilla kyllingen.net

Test case:

   struct Foo
    {
        invariant() { }

         disable this(this);

        Foo bar()
        {
            Foo f;
            return f;
        }
    }

When presented with the above, DMD complains:

bug.d(10): Error: struct bug.Foo is not copyable because it is annotated with
 disable

If the struct invariant is removed, the code compiles just fine.

--
Apr 30 2014