On Friday, 8 May 2020 at 14:16:10 UTC, foerdi wrote:
Hi d community,
I got a strange behavior since dmd 2.090 (dmd 2.089 is the last
working version).
See this reduced code: https://run.dlang.io/is/yoyHXC
I would expect that foo() returns 2.
My guess in foo is: The return value of val is saved locally as
a ref int and then the destructor of S is called (set the local
cache to 0). Now the ref value is dereferenced and returned.
Now I am unsure if this is a bug or an undefined behavior that
I don't know.
If this is a bug, then I don't know how to call it for the bug
tracker.
I hope you can help me with this problem.
PS: This is only tested on my Linux system and on run.dlang.io.
- foerdi
Gets even weirder because this fixes it LOL???
int foo()
out { }
do
{
return bar.val;
}
What the??