Archive for March 11th, 2016

Pointer or reference: no difference?

Friday, March 11th, 2016

There was some discussion recently on Twitter or something, with people claiming that there was no difference between a pointer and a reference for the compiler. Well it’s “mostly true” but in some critical cases it’s very wrong.

In fact, it is so wrong that in the past I was forced to remove all references from some classes in our codebase, because they broke our binary serialization system.

I’m not going to spoil it for you, it’s more fun if you just run the following test first with a pointer then with a reference, and see what happens.

Surprised, like I was? You should not be, it is a perfectly normal, expected and documented behavior. The compiler does exactly what it should be doing.

But it shows that pointers and references are not always “the same” w.r.t. generated code, nope.

shopfr.org cialis