For this function:
void foo_ref(const int& i) { cout << i << endl; }
Failed when I call it in gdb:
(gdb) call foo_ref(5) Attempt to take address of value not located in memory.
Of course, in this simple example, there is no need to use the link as a parameter. If I use the usual "int", then there is no problem.
Actually a real example is a template function, for example:
template<class T> void t_foo_ref(const T& i) { cout << i << endl; }
When "T" is "int", I have the problem mentioned above.
Is this a bug in gdb? Or maybe I could call such a function in gdb?
source share