Is is a Bug or just me?

foerdi dlang at foerdi.net
Fri May 8 14:16:10 UTC 2020


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


More information about the Digitalmars-d-learn mailing list