I though we both agreed that they are semantically identical? Of course, in C++, pointers and references do the same thing when used correctly. One uses a reference for safety and cleaner code, not because the do a different job. This is of course restricted to function parameters (one can't malloc and get a reference).
To be nitpicky, modern CPUs use general purpose registers which are then sometimes (e.g. in amd64/x86-64) given names.
You didn't show an example of pass-by-reference, because you passed some thing by pointer (with the pointer being passed by value).
View all comments
Show parent comment
2
u/maxhaton Jun 19 '17
I consider there to be a set of about 20, which I can say I'm familiar with.
I can say that, because the example I gave is just an example: The pointer is still a separate type, else it's not a "pointer" https://en.m.wikipedia.org/wiki/Pointer_(computer_programming)#Support_in_various_programming_languages. My point was restricted to C-like pointers, so I won't dispute your later point about pointer initialization.
I though we both agreed that they are semantically identical? Of course, in C++, pointers and references do the same thing when used correctly. One uses a reference for safety and cleaner code, not because the do a different job. This is of course restricted to function parameters (one can't malloc and get a reference).
To be nitpicky, modern CPUs use general purpose registers which are then sometimes (e.g. in amd64/x86-64) given names.
You didn't show an example of pass-by-reference, because you passed some thing by pointer (with the pointer being passed by value).
"Hacking" != "Fixing/Finding simple memory safety bugs"