5 ms·
If the compiler would know the stack size, we wouldn't have StackOverflow
by mendelab 2y ago
If the compiler would know the stack size, we wouldn't have StackOverflow
- vbezhenar 2y agoIs it hard to implement? It must be forbidden to have loops in the potential call graph. So, basically no recursion, direct or indirect. In this case, compiler with global visibility can calculate maximum call stack depth. I mean, it doesn't sound particularly hard technically, but is it too limiting for developer?
- Liquid_Fire 2y agoIt's not so easy for the compiler if you use virtual functions (dynamic dispatch), dynamic linking, function pointers etc as the complete call graph might not be known at compile time.