Automatic object
An automatic variable is a variable whose value, behavior, or lifetime is managed implicitly by a programming language or shell rather than controlled entirely by the programmer.
Modern C
An automatic variable is a C variable whose storage is created on entry to its enclosing block and released when execution leaves that block.
- How it is used
- Explains when local objects exist, including across recursive calls and jumps within a block.
- How deep it goes
- Defines ordinary lifetimes, works through a compound-literal case, and illustrates storage setup; sets aside separate VLA and temporary-object rules.
- Examples
- Uses a goto-driven compound literal and its printed pointer comparison, then contrasts unoptimized and optimized assembler versions.
- What you can do after
- Evaluate/understand when an ordinary local object exists without mistaking its declaration or initialization for the start of its lifetime.
Modern C, Third Edition
An automatic variable is a C object with automatic storage duration, normally created on entry to a block and destroyed on exit from it.
- How it is used
- Explains local-object lifetime and pointer validity across block entry, recursion, and repeated execution.
- How deep it goes
- Works through block-lifetime rules and a compound-literal jump example, then illustrates stack setup without making it a language requirement.
- Examples
- Uses a `goto` loop, its printed pointer comparisons, and unoptimized and optimized assembler listings.
- What you can do after
- Diagnose/debug with it whether local objects and pointers remain valid across jumps, repeated evaluations, and recursive calls.
Read how Modern C, Third Edition explains automatic object →
Related concepts
- recursionproduced by · Recursion is a computational technique in which a definition or procedure refers to or invokes the same definition or procedure, directly or indirectly.
- lifetimeuses · A lifetime is the interval during which a program entity exists and remains valid or accessible under the applicable language rules.
- objectkind of · A computational object is a runtime entity or structured value representing data, state, or a resource, with properties or operations defined by its programming model.
- stackpart of · A stack is a data structure that adds and removes elements at one end, following last-in, first-out order.
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.

