Is it recommended to use Variable Length Array (VLA) with built-in functions in C?

How does the VLA allocate memory on the stack, will they cause any problem if we include a function containing them? I think because of the same alloca behavior, i.e. storing objects on the stack, compilers avoid embedding such functions (?).

+4
source share
2 answers

While a (non-standard) function allocagives an object whose lifetime is the calling function, the VLA lifetime is the block in which it is declared. However, the attachment is not related to any of them. A function call whose body is nested is still a function call, and the objects that it receives through allocacease to exist when it semantically returns, and not when the processor executes a ret statement or equivalent.

+4
source

, , VLA ( ), - . , , /, . , , .

-3

Source: https://habr.com/ru/post/1669421/


All Articles