[Issue 19430] wrong code for `this =`, corrupted memory issue

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 24 13:35:57 UTC 2018


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

Stanislav Blinov <stanislav.blinov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.blinov at gmail.com

--- Comment #1 from Stanislav Blinov <stanislav.blinov at gmail.com> ---
I don't see wrong code here.

`this = ` is `this.opAssign(rhs)`. That opAssign in this case is implicit, copy
is omitted.

Add

void opAssign(S rhs)
{
    i = rhs.i;
    puts("a");
}

the output will be

c
a
d
d

--


More information about the Digitalmars-d-bugs mailing list