4.4.2.2 Automatic Storage Duration Objects

Objects with automatic storage duration, such as auto, parameter objects, and temporary variables, are allocated space on a stack implemented by the compiler. Temporary objects might be placed on the stack as well. The stack used by MPLAB XC8 and the 8-bit AVR devices is described in 4.2.3 Stacks.

Since objects with automatic storage duration are not in existence for the entire execution of the program, there is the possibility to reclaim memory they use when the objects are not in existence and allocate it to other objects in the program. Typically such objects are stored on some sort of a dynamic data stack where memory can be easily allocated and deallocated by each function. Because this stack is used to create new instances of function objects when the function is called, all functions are reentrant.

The standard const qualifier can be used with auto objects and these do not affect how they are positioned in memory. This implies that a local const-qualified object is still an auto object and will be allocated memory in the stack of data space memory.