C++ call stack not in standard?

孤者浪人 提交于 2020-01-04 06:04:20

问题


Does the C++ standard talk about the call stack? It's common knowledge how stack and heap are used in C++, but I was reading through the standard and found no mention of it.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf

Is this something that's left up to the compiler implementation, but everyone agrees on, or did I miss something while browsing the doc?


回答1:


It isn't mentioned in the standard. Neither the stack nor the heap are. The standard describes the syntax and the semantics(the behavior) of C++ programs. The implementations choose to implement it as they wish.

However when you see how calls to functions must behave, there isn't a really wide choice. There has to be some sort of a stack to store local variables!




回答2:


The standard talks about storage duration instead of stack and heap. How those are implemented is up to ... implementation.



来源:https://stackoverflow.com/questions/6876043/c-call-stack-not-in-standard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!