[Issue 6187] New: compiler could use move semantics for appending	temporaries to an array
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Jun 21 04:57:47 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6187
           Summary: compiler could use move semantics for appending
                    temporaries to an array
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com
--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-06-21 04:52:58 PDT ---
Currently, the following code:
import std.stdio;
struct S
{
   int x;
   this(this) { writeln("postblit"); }
   ~this() { writeln("dtor"); }
}
void main()
{
   S[] arr;
   arr ~= S();
}
outputs:
postblit
dtor
But it could have move semantics.  However, the runtime function which appends
data does not know whether the given data to append is an rvalue or not.  For
example, the following cannot have move semantics:
S s;
s.x = 1;
arr ~= s;
writeln(s.x);
So the compiler must give an additional flag (or call a separate runtime
function) when appending an rvalue.  When the compiler does this, flip the bug
to a druntime bug and assign it to me, and I'll fix the runtime.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list