[Issue 20809] return statement might access memory from destructed temporary

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 18 10:37:44 UTC 2021


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

--- Comment #9 from foerdi <dlang at foerdi.net> ---
Recently I discovered an interesting fact: this error or regression has also
affected the std RefCounter.

https://run.dlang.io/is/PMyy0W
```d
import std;

int foo()
{
    return refCounted(2); //(alias this) .refCountedPayload has ref return
}

void main()
{
    writeln(foo()); // foo() is corrupted
    assert(foo() == 2); // foo() is corrupted
}
```

I am surprised that this issue has not been more noticeable.

--


More information about the Digitalmars-d-bugs mailing list