In `void f(void) { unsigned n = 0; { unsigned x = n + 1; } }`, `x` is an automatic object. Its lifetime belongs to the execution of the inner block: it begins when execution enters that block and ends when execution leaves. The initializer supplies its value; it does not start its lifetime. section 13.2.2 section 13.3
TAKEAWAY — Storage duration answers how long an object exists, not whether it has been initialized.
- Block-scope variables and compound literals without `static` generally have automatic storage duration. Ordinary automatic objects live for one execution of their defining block; variable-length arrays and temporary objects need separate rules. section 13.2.2
- Each recursive call creates a separate local instance. Do not confuse repeated execution within one block with a recursive call that enters a new instance of the block. section 13.2.2 section 13.3
- The address-of operator `&` cannot be applied to an object declared `register`. This prevents taking its address and gives the compiler useful information about aliasing. section 13.2.2
Jumping past a compound literal
In `fgoto`, `goto` returns execution to a label without leaving the function’s block. Each evaluation of `&((unsigned){ j, })` in that block refers to the same compound-literal object, while its value is set again. For `fgoto(2)`, the second printed line therefore reports that `p` and `q` are equal and `*p` is `1`; the pointers remain valid. The example makes the distinction between an object’s lifetime and repeated evaluation of its initializer observable. section 13.3
Listing 13.3 A contrived example for the use of a compound literal
void fgoto(unsigned n) {
unsigned j = 0;
unsigned* p = nullptr;
unsigned* q;
AGAIN:
if (p) printf("%u: p and q are %s, *p is %u\n",
j,
(q == p) ? "equal" : "unequal",
*p);
q = p; 1
p = &((unsigned){ j, });
++j;
if (j <= n) goto AGAIN;
}
The `goto` example exposes how repeated evaluations can update one automatic compound literal without creating a new object on each iteration. section 13.3
On one illustrated machine, a function reserves stack space for its automatic objects on entry, then initializes selected objects with later instructions. That layout helps explain why reserved space need not already hold initialized values, but it is a machine-model illustration, not a required physical representation: an optimized version can use a different layout. In threaded code, prefer function arguments and automatic variables for data a thread uses locally. section 13.5 section 20.8

