On Monday, 20 September 2021 at 15:35:02 UTC, Ferhat Kurtulmuş wrote:
I thought it's stack-allocated and scoped.

It is.

But when I try to return a class instance from a function, it still works?

dmd only makes that an error if you specify `@safe` and i think `-dip1000`. Try adding one or both of those and recompiling and see what happens.

Note that even if the compiler doesn't error on it, it is undefined behavior to return the stack reference so be sure to treat it right.

Reply via email to