o_yeah
o_yeah

Reputation: 788

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?

Upvotes: 1

Views: 308

Answers (1)

ic_Engineer
ic_Engineer

Reputation: 314

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

Upvotes: 2

Related Questions