u/Longjumping_Ad_8175

What's the point of using local arrays if there is no guarantee that the stack won't be overflowed?

Basically title. I feel deterred from using local arrays because I cannot check in my C code if the allocation was successful.

Is it true that in C you cannot guarantee that a local array will not overflow the stack? Isn't it detrimental to any memory safety critical application. For a stack allocation, aren't there any guarantees in the C language that could help me make at least some decision about the safety of it?

If memory safety was critical, should local arrays be avoided for the possibility of stack overflow – and only dynamic allocation should be used?

Malloc gives you NULL when heap has not enough space but alloca and local arrays don't give any warning when stack has no space. Why does alloca have no similar system? I get that you can check the size and calculate the remaining space on the stack using system's api and that'd be a guarantee that the space won't be a problem.

reddit.com
u/Longjumping_Ad_8175 — 8 hours ago