Stack Overflow C++

1 day ago 1
ARTICLE AD BOX

I'm reasonably new to C++ coding and have been doing a lot of reading on the stack vs heap question.

Most of the documents I'm reading are quite old, and a lot of the advice is quite nebulous, such as "Put big data structures on the heap or you might overflow the stack" etc.

In 2026, with a main thread stack size of 8MB, I'm looking for reasons to not use the stack for almost everything (growing data structures such as vector etc being an obvious exception, though I know there are a few other cases where LIFO doesn't make sense).

I also struggle to understand why something so catastrophic as a stack overflow seems to be generally avoided by a vague "finger in the air" guess as to what libraries etc will be using. This feels very dangerous and I can't help suspecting that I've seen stack overflow crashes in some pretty expensive and widely adopted software.

So my questions for you experienced folk are:

In 2026, is it not preferable to use the stack much more than our ancestors?

What would you advise as a way of getting a definite value for amount of stack remaining, to categorically stop stack overflows?

Read Entire Article