From the point of view of the C programming language, all that is guaranteed is that variables with automatic storage time (local variables) will have their own memory created and destroyed when necessary, when the program is launched. As far as I know, this full implementation is defined if and when memory for each variable will be allocated and freed.
In extreme cases, variables may not even get the memory assigned to them if they are local variables that can be stored inside registers. In this case, many different variables can have the same location in memory, although technically speaking, they all exist at the same time, provided that the compiler could notice that the variables should never coexist. On the other hand, space for variable-length arrays cannot be allocated until the size is known, therefore, if the compiler cannot perform static analysis and determine that memory is required for the array earlier, you may have to defer allocation until until the point where the VLA is declared.
Hope this helps!
templatetypedef
source share