Automatic storage
Automatic storage duration is a C storage duration in which an object's storage is associated with execution of its defining block or function.
Modern C
Automatic storage duration is a C storage duration in which an object's lifetime is associated with execution of its defining block, except for variable-length arrays and temporary objects.
- How it is used
- Distinguishes the runtime lifetime of ordinary local objects from other C storage durations.
- How deep it goes
- Defines categories and block lifetimes, explains recursive instances and register restrictions, and sets VLAs and temporary-object lifetimes apart.
- Examples
- Uses shadowed local variables and a saved pointer to separate identifier visibility from object lifetime.
- What you can do after
- Diagnose/debug with it by checking whether a local object's lifetime has ended and whether it was explicitly initialized.
Modern C, Third Edition
Automatic storage duration is a C storage duration in which an object's storage is created on entry to a relevant block or function and released when execution leaves it.
- How it is used
- Uses automatic storage to reason about local-object lifetime, recursive instances, and valid access separately from identifier visibility.
- How deep it goes
- Defines eligible automatic objects and the usual block-lifetime rule, while flagging VLAs and temporaries as exceptions.
- Examples
- Uses a shadowed local variable and a saved pointer, plus unoptimized and optimized gcc x86_64 assembler listings.
- What you can do after
- Diagnose/debug with it by checking whether a local object remains alive, including across shadowing and recursive calls.
Read how Modern C, Third Edition explains automatic storage →
Related concepts
- compound literalused by · A compound literal is a C expression consisting of a parenthesized type name followed by an initializer that creates an unnamed object.
- variable-length arraycontrasts with · A variable-length array is an array whose bound is determined at run time rather than fixed as a compile-time constant.
- consistency modelused by · A consistency model is a formal specification of how operations on state may be ordered and what values those operations can observe.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

