|
|
|
|
|
by 1718627440
188 days ago
|
|
> What if the function is implemented in a shared library If it is in the public API/ABI of a shared library, than the calling semantics including lifetime and ownership rules are part of the public interface, so of course the compiler can't just change it. You the programmer are responsible for drawing abstraction boundaries and choosing the interface. > It works the exact same way in C++, though. Only if write C in C++. The issue here are references, of which the compiler figures out whether this should work like a value or like a pointer. This doesn't exist in C, there the programmer needs to make up its mind and choose. The whole type conversion by making a copy issue also doesn't exist there, because either the type matches or the compiler throws an error. |
|
> The issue here are references, of which the compiler figures out whether this should work like a value or like a pointer.
I'm not sure I understand. A C++ reference always has reference semantics. Can you give an example?