2 ms·
> Compiler will tell you what amount of stack a function will use If you ask a compiler how much stack a function will use the answer for a non-trivial compile
by chrisseaton 5y ago
> Compiler will tell you what amount of stack a function will use
If you ask a compiler how much stack a function will use the answer for a non-trivial compiler for a complicated language is always going to be 'it depends...'
- MaxBarraclough 5y agoAs I mentioned in my other comment, AdaCore's GNATstack tool appears to be capable of reporting this information conservatively but with enough accuracy to be useful. https://www.adacore.com/gnatpro/toolsuite/gnatstack https://www.adacore.com/gnatpro/toolsuite/gnatstack
- user5994461 5y agoThe tool will simply freak out when there is any recursion or indirect call. It's not helpful since it happens everywhere in standard libraries and non trivial programs (forget about sorting, any regex, parsing source code, linting, etc...). The only use case is for real-time embedded code -typically in aerospace- where the coding guidelines prohibits you from using any recursion at all and you have to prove the highest stack usage fits into the chosen microcontroller.
- MaxBarraclough 5y agoI mentioned such restrictions in my other comment, [0] I should have mentioned them here too. [0] https://news.ycombinator.com/item?id=27642406 https://news.ycombinator.com/item?id=27642406
- megous 5y agoOriginal article is about C compiled programs, not about arbitrary languages. It's not a huge problem in C.