> On Mon, Mar 2, 2015 at 3:56 PM, Anthony J. Bentley <anth...@cathet.us> wrote: >> VLAs are a fundamentally broken feature because they do not allow any >> error checking. alloca() is the same. >> >> -- >> Anthony J. Bentley >> > > But when do you ever do error checking of stack size? Is recursion a > fundamentally broken feature because it doesn't allow any stack > overflow error checking? > > -emg
The compiler can does the check each time it increment the size of the stack. This was common in the old times, when collisions between stack and heap were commons. Today is a non sense. For example in linux you have a stack with a fixed size of 8MB (by default), and when you are out of it you receive a SIGSEGV, so it is secure to use it (secure in the sense you are not going to trash heap with stack data). For the example of emg, I think is correct because the size of path and d_name are limited, and it is equivalent to declare buf like 'char buf[FILENAME_MAX]' but using less space in the stack, that is always good.