Is the following code safe and portable?
void funcB(int *pA)
{
// Do something w/ pA
}
void funcA(int a)
{
funcB(&a);
// Do something else w/ a
}
My understanding is that on many systems, function parameters get placed in the CPU registers and not on the stack. So you're really passing the address of the register to the function, the contents of which will then be pushed onto to the stack so that the register can then be used for the parameter of funcB. So, in reality, when you dereference pA in funcB, you'll be getting the address pA instead the contents of a from funcA. Is my reasoning correct or am I totally off-base?