this->skeleton is a Skeleton&. auto will infer Skeleton. A copy is created. The copy is a shallow copy, which gets destructed at the end of the block. Which smokes the internals of the original Skeleton. Which makes things go boom.

auto is now banned in my C++ code bases.

@Ronflaix I'd really love to understand the rational behind auto and &. It's such a stupid foot gun. Like, when would you ever want to turn a & into a local copy?

@badlogic I guess that for types smaller than a pointer returning a reference might not be worth it?

@Ronflaix oh, I'm not saying auto should by default "infer" a reference. For me the most intuitive way auto should work: type of LHS == type of RHS

But I'm a simple boi and likely overlook some terrible C++ magic that needs to be adhered to.

Follow

@badlogic @Ronflaix

That would create a complementary footgun, where you are preserving a reference to e.g. an entry in a vector (acquired via e.g. `front()`) across operations that invalidate it and it's not obviously recognizable due to auto.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.