4 ms·
> "recursion" is not a concept in C. Just function calls. There are indeed C compilers that don't support recursion (or function re-entrancy). What does the st
by vardump 9y ago
> "recursion" is not a concept in C. Just function calls.
There are indeed C compilers that don't support recursion (or function re-entrancy). What does the standard say about stacks?
- jstimpfle 9y agoI'm not a standards guy, so I might be wrong, but this is the only reference to recursive calls that I could find from the C11 draft [1], Section 6.5.2.2 item 11: Recursive function calls shall be permitted, both directly and indirectly through any chain of other functions. Stacks, I don't know. I only care about the concept (and semantics) of function calls. The call stack is an implementation detail. I wouldn't be surprised if the concept of a call stack was not part of the standard. [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
- comex 9y agoIndeed, it's not. In the case of what we'd usually call stack-allocated variables, the C standard just uses the phrase "automatic storage duration", and defines their lifetime without explicitly referencing a stack: > For such an object that does not have a variable length array type, its lifetime extends from entry into the block with which it is associated until execution of that block ends in any way. (Entering an enclosed block or calling a function suspends, but does not end, execution of the current block.) If the block is entered recursively, a new instance of the object is created each time. The initial value of the object is indeterminate.