2

If I'm passing parameters as call by value-return and call a void function, will the local values within the function still be copied to the corresponding values in the caller function even though the called function doesn't return? For example:

int x = 4;

void foo(int a) {
    a = 8 + 8;
}

int main() {
    foo(x);
    print x;
}

Will the value printed be 4 or 16? My hunch is that because foo never returns, the local value for a within the stack frame of foo never gets copied back to the value for x in the stack frame for main, but I wanted to double check.

1 Answers1

0

It will print 4 because sending by value will change the copy not the original variable which is x in your example.