During a C++ program execution does stack frame of a particular function always have a constant size or compiler is allowed to do dynamic stack management in some cases, something similar to what alloca() function does? to better describe it I mean offset of a particular local variable or object in the stack frame may change at different executions of function
At least in most typical implementations, the stack frame for a variadic function varies depending on how many variables are passed. For example:
printf("%d", 1); // stack frame contains 1 pointer, one int
printf("%d %d", 1, 2); // stack frame contains one pointer, 2 ints.
Whether the implementation is particularly similar to alloca
depends on the implementation though (especially since alloca
isn't standard, so how or even if it's implemented may vary).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With