[GSoC] Pass-by-value opAssign called with a ref doesn't call postblit, possible bug.

dsimcha dsimcha at yahoo.com
Thu Jun 23 11:05:26 PDT 2011


== Quote from Cristi Cobzarenco (cristi.cobzarenco at gmail.com)'s article
> --bcaec520ef993a51fd04a664c3d6
> Content-Type: text/plain; charset=ISO-8859-1
> Ok a follow-up to my previous email, it has nothing to do with opAssign in
> particular. Any function that takes an argument by value, pass it the result
> of a function that returns a reference and it won't call the postblit.
> Calling it with a ref argument on the other hand works properly:
> import std.stdio;
> struct Test {
> this( this ) { writeln( "Test.this(this)" ); }
> ~this()      { writeln( "Test.~this()" );    }
> }
> ref Test returnsRef( ref Test x ) { return x; }
> void takesVal( Test x ) {}
> void takesRef( ref Test x ) {
>      takesVal( x );
> }
> int main() {
> Test x;
>  writeln( "-- with ref argument (works)" );
>  takesRef( x );
>  writeln( "-- with ref return (doesn't work)" );
>  takesVal( returnsRef( x ) );
>  writeln( "-- done");
>  return 0;
> }
> I'm starting to be pretty sure this is a bug.

Looks like a bug to me.  Please file.  Also, in general if in doubt just file it.
 If it's not a bug, someone will clarify that and close it on Bugzilla.


More information about the Digitalmars-d mailing list