Possible bug in RVO?

Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 4 18:03:18 PDT 2016


On Monday, 4 April 2016 at 21:31:08 UTC, Ali Çehreli wrote:
> On 04/04/2016 09:36 AM, Anonymouse wrote:
>> On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote:
>>>     [...]
>>         assert(x.aa.length > 0);  // <-- boom
>>> [...]
>>
>> No idea myself but that's where it seems to go wrong.
>
> Looks like a bug. Just to make it more visible:
>
> auto clobber(ref Set x, ref Set o) {
>     writefln("entered clobber    - x.aa: %s", x.aa);
>     Set ret;
>     writefln("did not touch x.aa - x.aa: %s", x.aa);
>     ret.aa = x.aa;
>     return ret;
> }
>
> x.aa changes during the second call:
>
> entered clobber    - x.aa: [1:true]
> did not touch x.aa - x.aa: [1:true]
> entered clobber    - x.aa: [1:true]
> did not touch x.aa - x.aa: []          <-- What happened?
>
> Ali

I filed an bug report here: 
https://issues.dlang.org/show_bug.cgi?id=15869


More information about the Digitalmars-d-learn mailing list