C++ call stack not in standard?

2019-07-12 08:49发布

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?

2条回答
叼着烟拽天下
2楼-- · 2019-07-12 09:02

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

查看更多
Ridiculous、
3楼-- · 2019-07-12 09:25

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!

查看更多
登录 后发表回答