On Monday, 13 June 2016 at 14:16:58 UTC, jmh530 wrote:
So returning a reference to something on the stack is a bad idea, but copying the value would be fine.

This is easy enough to get wrong elsewhere too. I recall having an issue with a foreach, until I added a 'ref' to it. Looking at the addresses all pointing to the same spot (the temporary) which can add curiously subtle bugs, or blatantly obvious ones.

Reply via email to