I was given some code in which some of the parameters are pointers, and then the pointers are dereferenced to provide values. I was concerned that the pointer dereferencing wou
Here's the difference in the generated assembly with g++. a.cpp
is pointers, b.cpp
is references.
$ g++ -S a.cpp
$ g++ -S b.cpp
$ diff a.S b.S
1c1
< .file "a.cpp"
---
> .file "b.cpp"
4,6c4,6
< .globl __Z7MyFunc1PiS_
< .def __Z7MyFunc1PiS_; .scl 2; .type 32; .endef
< __Z7MyFunc1PiS_:
---
> .globl __Z7MyFunc1RiS_
> .def __Z7MyFunc1RiS_; .scl 2; .type 32; .endef
> __Z7MyFunc1RiS_:
Just the function name is slightly different; the contents are identical. I had identical results when I used g++ -O3
.