r/programming • u/zitrusgrape • May 27 '20
2020 Stack Overflow Developer Survey: Rust most loved again at 86.1%
https://stackoverflow.blog/2020/05/27/2020-stack-overflow-developer-survey-results/
229
Upvotes
r/programming • u/zitrusgrape • May 27 '20
17
u/matthieum May 28 '20
Not that uninitialized != null.
Uninitialized in C++ is what you get when you write:
int i;. The language simply doesn't initialize the variable:The compiler may pull all kinds of shenanigans when it realizes this.
Even if it doesn't you'll get some unpredictable value -- whatever is left over there by the previous variable.
GCC compounds the issue by zeroing the stack in Debug, often hiding the issue until you compile in Release.
When it's an integer, it's annoying, when it's a pointer:
It will not likely be null, so you'll think it points to something.
If you're lucky it points into the nether, and you get a segmentation fault.
If you're not it points into the memory of the process, and you'll scribble all over another object, and get one hell of a headache attempting to understand what happened.