Search code examples
c++stackcallstackfunction-call

C++ return value storage in a stack frame


int f(int a, int b){
    return a+b;
}

int main(){
    f(1,2);
}

In this example, when calling function f, there is not a specific variable storing the addition result of a and b. My question is: where will the result of a+b be stored?


Solution

  • it will be moved to a temporary registers.
    it will load the values, then call f(int,int) take a look to the disassembly: enter image description here