-preview=in might break code

Iain Buclaw ibuclaw at gdcproject.org
Mon Oct 5 11:32:52 UTC 2020


On Monday, 5 October 2020 at 09:53:37 UTC, Walter Bright wrote:
> On 10/5/2020 1:34 AM, Iain Buclaw wrote:
>> Furthermore, NRVO is implementation defined, which results in 
>> the same dmd/gdc/ldc making different decisions for "to ref or 
>> not to ref", and yet I see no one complaining about that.
>
> I don't see that as a to ref or not decision. It is an issue of 
> how many copies are made, there shouldn't be dangling 
> references to those copies, or it shouldn't NRVO it.
>
> I don't recall any case of NRVO breaking code since I invented 
> it 30 years ago, other than something that relied on the number 
> of copies.

I don't consider there to be any difference between the two as 
far as parameter passing is concerned.  As I understood from the 
review, the point of ref passing is to elide copies.  Because 
this is allowed as an optimization only, none of what it does 
should spill out into user code.  If people notice then something 
has gone wrong in the implementation.


More information about the Digitalmars-d mailing list