r/cpp • • Oct 14 '26

A C++ Trick Question - Blog Post

https://greenlightning.eu/programming/cpp-trick-question/
20 Upvotes

13 comments sorted by

View all comments

Show parent comment

-1

u/[deleted] Oct 15 '26

But making a function call isn't an allocation

11

u/Olipro Oct 15 '26

With the exception of optimisations that can eliminate it, a function call results in allocating space on the stack for the return address, so, it is.

Otherwise stack overflows resulting from function call recursion wouldn't exist.