Hacker News new | ask | show | jobs
by j_w 22 days ago
Would the compiler not allocate the memory contiguously on the heap in that case then? Seems like a reasonable thing to do.
1 comments

Nope. The C++ memory models is designed around no hidden/non-deterministic memory allocation.

If you try to allocate 10MB on the stack, that's the dev problem if the program fails, it's not the compiler job to guesstimate whether something will fit there or not (and it's impossible anyway, the compiler can't know all the stack sizes a program will ever run on).