3 ms·
Where's the problem? Compiler will tell you what amount of stack a function will use, if it's inlined it may not tell you for that function, but it will tell yo
by megous 5y ago
Where's the problem? Compiler will tell you what amount of stack a function will use, if it's inlined it may not tell you for that function, but it will tell you for the function the function was inlined to, which is what matters.
If the language is complicated and has generics or whatever, the programmer will have to do more work to understand it.
It's not a huge issue in C.
- 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.